Message 1 of 7
How to Force GC to clear memory after à BindXRef
Not applicable
01-14-2013
04:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, i have a issu when i use BindXRef.
I have 4 XREF in my dwg. so i use à Do / While for each XREF i have found.
It work fine but whrn the Xref is big File, i have the issue "Out Of memory".
So the question : How i can Force the GC to clear all memory not used.
My Think is to force the GC to Clear the memory before to use BindXRef() with only one XRef before to BindXRef with another.
Sorry for my english.
Here my code :
Dim LockDoc As DocumentLock = doc.LockDocument
Dim MemNumBoucle As Integer = -1
Dim CollXRef As New ObjectIdCollection
Do
CollXRef.Clear()
Dim xg As XrefGraph = db.GetHostDwgXrefGraph(True)
Dim root As GraphNode = xg.RootNode
Using tr As Transaction = db.TransactionManager.StartTransaction
For o = 0 To root.NumOut - 1 Step 1
Dim child As XrefGraphNode = CType(root.Out(o), XrefGraphNode)
If child.XrefStatus = XrefStatus.Resolved Then
Dim bl As BlockTableRecord = tr.GetObject(child.BlockTableRecordId, OpenMode.ForRead)
'i_ed.WriteMessage(vbCrLf & i_indent + child.Database.Filename)
' Name of the Xref (found name)
' You can find the original path too:
If bl.IsFromExternalReference = True Then
GestionAUTOCAD.EcrireSurLigneDeCommande(vbCrLf & "Xref path name: " + bl.PathName)
CollXRef.Add(bl.ObjectId)
'détection si le liage a été fait :
If MemNumBoucle <> root.NumOut Then
MemNumBoucle = root.NumOut
Exit For
End If
End If
End If
Next
'trouvé un xref --> Adding
If CollXRef.Count > 0 Then
Try
doc.Database.BindXrefs(CollXRef, False)
Catch ex As Exception
okErr = True
MsgBox("Erreur lors de la liaison d'un Xref" & vbCrLf & "--> Essayer de lier le premier niveau", _
vbOKOnly & vbCritical, _
"Erreur Système")
Finally
tr.Commit()
End Try
End If
End Using
GestionAUTOCAD.EcrireSurLigneDeCommande(vbCrLf & "-> " & CollXRef.Count.ToString)
Loop Until (CollXRef.Count = 0) Or (okErr = True)PS : the var MemNumBoucle is used for detection of XRef Not binding if this XRef is used in another XREf : Here a example :
- DWG
-- XREF : R+1
-- XREF : ARCHI
-------------- XREF R+1
In this example i cant BindXREf ('R+1') alone. I need to BindXRef('ARCHI') before