Ross asked:

> My app loads 3rd party DLL's.  There is a freeware 3rd party 
> DLL I distribute which has a memory leak in a rare situation. 
>  The DLL source is not available.
> Unloading the DLL doesn't free the RAM.  I guess Windows 
> doesn't keep track of RAM allocations within DLL's.  Is there 
> any ability to determine the RAM allocated by the DLL and 
> force this to be released when the DLL is unloaded?  I'm 
> guessing not but thought I would ask.

I think you're right. I'm not aware that the Win32 heap and/or memory
management tracks the module doing the allocating. Memory management is
a whole address space kind of thing and DLL's live in your address
space, essentially by definition.

However, you could track that information yourself by patching the DLL's
import table to redirect all it's memory allocation activity through
your own shim routines which track the allocations and frees and
forwards them through to the usual imported routine. Then you would have
the information to be able to release the leaked memory on unload.

You'd need to examine the DLL's import table with an appropriate tool to
see which APIs it uses to allocate memory, eithe a run-time library DLL
or direct API calls like VirtualAlloc/HeapAlloc, etc. to determine
whether this is feasible.


NZ Borland Developers Group - Delphi mailing list
Unsubscribe: send an email to with Subject: 

Reply via email to