Thank you very much to all for your replies.
Dnereb, I will try to set all the SelectionSet to nothing before the ending of the procedures (I believe that the only variables which can be the responsible of the leak of memory are SelectionSet variables. ). I didn't do it, I thought that It was enough to clear and delete this variables. I usually wrote
....
....
On Error Resume Next
objAcSelSet1.Clear
objAcSelSet1.Delete
On Error GoTo 0
End Sub
at the ending of procedures which uses SelectionSet variables. As all this variables were declared as local variables, I thought that VB releases the memory of this variables after the procedures, but perhaps the memory is not released. I will write in this forum again if it works.
Bryco thanks a lot for your reference to the discussion of autodesk forum. I read it and it gave me some ideas to solve the problem (Such as try to delete selection sets from the SelectionSets collection, the use of the function of memory to debug, etc. ). About the use of Erase statement: In my code I use some arrays of drawing entities, dynamic arrays (Example: Dim objAcEntArrVigas() As AutoCAD.AcadEntity) of one dimension, which are used to point to the elements of a selection set first, and then to sort the elements into array in a way that the order of the elements in the array is the same that some order of the entities pointed by the array in the drawing (I use this to make calculations of distances between sorted entities in the drawing later. ). As the array is a dynamic array, I use the Erase statement to release the memory used by the array before, and then I use ReDim to assign a new size of memory to the array:
....
....
Dim objAcEntArrVigas() As AutoCAD.AcadEntity
....
....
Erase objAcEntArrVigas
ReDim objAcEntArrVigas(0 To lng1)
....
....
Erase objAcEntArrVigas
End Sub
For a fixed-size array Erase only clear the array, It don't recover memory as you say, but I only use Erase with the dynamic arrays.
Keith and Bob thanks, about the selection sets in the routine where I have the problem (Is a routine to calculate forces and moments over the structural elements of the plane, like moments and forces over beams, etc. ) inside the procedure which has the max level of depth I have 4 selection sets, I think that there aren't many selection sets, and the number of elements of each set is less than 1000 (Perhaps sometimes one of this sets can reach this number of elements. ). I usually write:
Private Sub PlanoActualizar(blnPlanta As Boolean, intPlanta As Integer, blnReCalculables As Boolean _
, blnContinuar As Boolean, udtError As mdlUtilidades01.tError)
' DECLARACIONES:
Dim objAcSelSet1 As AutoCAD.AcadSelectionSet
....
....
....
' INSTRUCCIONES:
blnContinuar = True
blnError = False
Call ErrorAnular(udtError)
' Línea de errores no controlados.
' Line of not-controlled errors.
On Error GoTo linError0
' At the beginning of procedures I inicialize the SelectionSet variables.
' If I need to use a SelectionSet inside For....Next, I clear It in each loop, I don't create it again.
str1 = "PlanoActualizarAcSelSet1"
Set objAcSelSet1 = ThisDrawing.SelectionSets.Add(str1)
objAcSelSet1.Clear
If blnContinuar Then
....
....
....
End If
' Línea de errores no controlados.
' Line of not-controlled errors.
linError0:
If (Err <> 0) Then
Call ErrorRetornar(Err, udtError)
Resume linError0
End If
On Error GoTo 0
On Error Resume Next
' Clears the set of his items.
objAcSelSet1.Clear
' Delete the set.
objAcSelSet1.Delete
On Error GoTo 0
End Sub
After the execution of the routine all the selection sets which were created by the routines are deleted from the drawing, but the memory is not released. In some procedures I pass selection sets by reference, but these selection sets are destroyed when the execution comes back to the procedure where are declared.
Well, I will continue solving it... Many thanks (And sorry for my poor English. ).