ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
CGCarl Graff23/02/2008
Hi,

I have a VB 2008 application that is opening part drawings and saving them as eDrawings for about 4000 part files in a directory. It works but always returns an unhandled exception error after about 800 files are processed.

The error is:
Unhandled exception at 0x697223e9c in create_edrawings.exe:
0xC0000005: Access vialaton writing location 0x01000108.

Using task manager I can see memory leaking as the application is running - it drops from about 3GB to 1GB and then the error. I should note that I was told this same code ran on a different computer without crashing.

Basically EMmodelView is wrapped as AxEModel view and dropped as a control on a form.

The high level logic is basically the same as the sample VB6 app in the API (which I verified also leaks memory by putting it in a loop for 1000 iterations) as follows:

For each drawing file in directory

axEDrawing.OpenDoc(Path, False, False, False, "")
While _processing
Application.DoEvents()
End While

axEDrawing.Save(Path, False, "")
While _processing
Application.DoEvents()
End While

axEDrawing.CloseActiveDoc("")

Next

I do have two handlers as follows:

Private Sub axEDrawing_OnFinishedLoadingDocument(ByVal sender As System.Object, _
ByVal e As AxEModelView._IEModelViewControlEvents_OnFinishedLoadingDocumentEvent) _
Handles axEDrawing.OnFinishedLoadingDocument
_processing = False
End Sub


Private Sub axEDrawing_OnFinishedSavingDocument(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles axEDrawing.OnFinishedSavingDocument
_processing = False
End Sub

Things I know or suspect:
1. I think it was ran before using VB2005 and now it is VB2008
2. I think it was ran before on a single core 32 bit processor and it is now on a dual core 64 bit processor
3. The OpenDoc call worries me because it creates a new thread and maybe the dual core is handling different than the single core.
4. The memory leak worries me.

Specific Questions:
1. I believe there is a dispose function - should I be using it instead of CloseActiveDoc to release memory?
2. There are a few compiler options - one is register for COM interop - is this or another compiler setting vitally important?
3. If I can't find another way is it plausible to create and destroy the com object every say 100 files to clear resources?

So if anyone has gone down this path and can point me in the right direction I would be very grateful. I am not looking forward to reading a 1600 page book on COM / .net interoperability.

Thanks,
Carl