
Memory Leaks when using Shellexecute
Steven E Serrell
Quote:
>I managed to use ShellExecute to open a Visual Basic app that opens and
>modifies
>an Access database, but when I close it and then close the VC++ app
>my debug info reports memory leaks. I've examined my VB code
>and can't seem to find anything that is left undone. Does anyone out here
>have any sugestions
The MFC&T debugging functions and macros can only see what goes through
'new', 'malloc', 'delete', etc. They can't see inside 'AllocMem' (sic?) or
'ShellExecute'. If, just before 'exit' returned your program to the OS, you
owed a zillion megabytes, those debugging macros will not report it. I
suspect you could detect such a leak by examining your low-level memory
handles (as per /Advanced Windows/ by Jeff Ritcher), but you would be
hard-pressed to detect memory loss by another program. The OS reclaims
everything even if your child app does not explicitely free anything, so by
the time you exit (according to your sequence of events), all the VB is
washed out of memory.
Besides, the "memory fairy" inside VB always cleans up after anything you
do (except, of course, for API calls like 'AllocMem').
To test this, write a tiny non-VB program that spoofs whatever your child
app was doing to your main app. Forget about the Jet database - just make
sure the program permits your main program to follow its normal paths. See
if you still have the leak. It is probably just a normal memory leak from
somewhere in your logic.
-- Phlip
======= http://users.deltanet.com/~tegan/home.html =======
-- My opinions are mine alone!
If someone agrees with me, I'l change them! --