I didn't know that was possible. I'll investigate. Thanks.
-----Original Message----- From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Paul Heinz Sent: Sunday, 7 August 2011 4:24 p.m. To: NZ Borland Developers Group - Delphi List Subject: Re: [DUG] DLL memory leaks 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. Cheers, Paul. _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe