[CE U17] COM/Interop does not release memory

It's quite similar to https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/201080/mstn-ce-u14-vba-and-com-interop-does-not-release-memory but this time it happens while accessing child elements.

When I run this code and do 1Mio Runs, my memory does not get released:

         CellElement element = comApp.ActiveModelReference.GetElementByID(elementId) as CellElement;

         for (int i = 0; i < nRuns; i++)
         {
            ElementEnumerator subElements = element.GetSubElements();

            while (subElements.MoveNext())
            {
               //...
            }

         }


My DGN only contained one Cell Element with 7 Shape Elements. Nothing fancy or special. I was able to exhaust all my RAM with this simple function. A DGN change did not released the memory either.
I've tested this on 10.16.02.34 and 10.17.01.62 and both behaved the same.

Parents Reply
  • I've tried it with VBA with the Code below and same results. Switching DGNs also did not freed up the Memory.

    Public Sub MemoryBenchmark()
       Dim elements As ElementEnumerator
       Set elements = ActiveModelReference.Scan
       Dim i As Long
       
       Do While elements.MoveNext
          Dim element As element
          Set element = ActiveModelReference.GetElementByID(elements.Current.ID)
          
          If (element.IsCellElement) Then
             Dim cellElement As cellElement
             Set cellElement = element.AsCellElement
             
             For i = 1 To 1000000
                Dim subElements As ElementEnumerator
                Set subElements = cellElement.GetSubElements()
                
                Do While subElements.MoveNext
                Loop
             Next
          End If
       Loop
    End Sub

    I added the DGN I used.

    test_memory.dgn

    Mit freundlichen Grüßen / Best regards
    Jean-Pierre Hundhausen

    |  AB_DATE Engineering  Software   |  ab-date.de  |

Children