Batch Process, Win9x Resource leak?

regarding the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Batch Process, Win9x Resource leak?

Postby IDEAL Software Support » Thu Dec 16, 2004 4:52 pm

We create huge numbers of VPE documents in a batch process. This means, in a loop of hundreds of iterations we permanently call OpenDoc(), export for example the document contents to image files and call CloseDoc() afterwards. Under Win9x we notice that the User resources are shrinking continuously until no resources are left over. Is this a bug in VPE, does VPE have a memory leak?

A: No, this is not a problem of VPE. It is caused by the design of Win9x: with every call to OpenDoc(), VPE creates internally the invisible windows (Frame, Client, Toolbar, Statusbar, etc.) which are needed for the preview. When calling CloseDoc() all those windows are destroyed and therefore the allocated space on the User Heap is freed.

However, Windows itself does not compact the User Heap unless process control is returned to the Windows subsystem. After deep investigation of this issue, we encountered that you should execute the following code in order to let Windows shrink the User Heap:

VpeCloseDoc();
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

Immediately after calling VpeCloseDoc(), the code above yields process control back to Windows, which will make Windows compact its User Heap. Calling VpeDispatchAllMessages() or Sleep() does NOT help.

NOTE: The problem described above does only occur, if you are running a batch process which does not interact event driven with the user and which executes hundreds of OpenDoc() / CloseDoc() sequences without yielding process control regularly back to Windows. If you are using VPE normally in a GUI application which is driven by events - as all the demos shipped with VPE are - there will no such problem arise, because process control is automatically returned to Windows after each document has been created.
IDEAL Software Support
 
Posts: 1589
Joined: Thu Nov 18, 2004 4:03 pm

Return to VPE Frequently Asked Questions

Who is online

Users browsing this forum: No registered users and 2 guests