ActiveX control causes memory leak

M

Mishaev Mark

Hi,

I'm using ActiveX Visio Control in my VB.NET application.
The application loads a "heavy" Visio drawing (about 150 pages; about 10 shapes in each page) and iterates through all shapes to retrieve the required info.

The code snippet:
private sub GetDrawingInfo(currentDoc as Visio.Document)
Dim pageObj as Visio.Page
Dim shapeObj as Visio.Shape
Dim currPage as Visio.Page
Dim currShape as Visio.Shape
Dim pagesCount,shapesCount as Integer
Dim pageIndex,shapeIndex as Integer

pagesCount = currentDoc.Pages.Count
For pageIndex = 1 to pagesCount
currPage = currentDoc.Pages.Item(pageIndex)
'//-----Some Processing
shapesCount = currPage.Shapes.Count
For shapeIndex = 1 to shapesCount
currShape = currPage.Shapes.Item(shapeIndex)
'//------Some Processing
next shapeIndex
next pageIndex
end sub

The problem is that as soon as the page loop is going on the function execution is decelerated.
I've checked in the debugger and just the assigning of the next page object to the "currPage" reference is very slow (currPage = currentDoc.Pages.Item(pageIndex).
The interesting thing is that if I reclaim unused memory by calling garbage collector after each pages' loop iteration, that execution time is reduced in non-proportional way, for example instead of 180 secs it becomes 9 secs.

How can I explain this??????

Please help.

Thanks,
Mark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top