www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - full allocation debugging for GC logger

reply Alan Knowles <alan akbkhome.com> writes:
This may be useful for anyone wanting to debug memory leaks.


It's basically a large addition to the logger code, so that it can find 
out the calling location that tried to allocate memory, stores this in 
the Log.file item.

Then when you do a genCollect/fullCollect - it lists where memory was 
allocated that can not be free'd yet.

Code changes are public domain - so walter is free to add what he thinks 
is a good idea....

(note I had to use the demangle code from gdb, as I think calling 
std.demangle would affect the pool...)

for Freebsd/gcc - you need to compile with the options:

gcc -Wl,-export-dynamic -lexecinfo .......


Example output:

         size = 8, parent = 80fc000 - Mailer.lib.tls.Tls._ctor():34
         size = 64, parent = bfbfe488 - Mailer.lib.tls.Tls._ctor():34
         size = 24, parent = 285aff80 - 
         size = 5, parent = bfbfe488 - 
         size = 24, parent = bfbfe488 - 
         size = 104, parent = bfaed8c8 - Mailer.main.MailerRun():167
         size = 16, parent = bfaed8c8 - 
         size = 5, parent = bfbfe488 - Mailer.main.MailerRun():208
         size = 104, parent = bfbfe488 - Mailer.main.MailerRun():167
Sep 03 2008
parent "Vladimir Panteleev" <thecybershadow gmail.com> writes:
On Wed, 03 Sep 2008 11:29:29 +0300, Alan Knowles <alan akbkhome.com> wrote:

 This may be useful for anyone wanting to debug memory leaks.
I started writing a memory debugger framework, but didn't get around to finishing it yet. It's working and useable, but doesn't have any documentation and some more features I'd like to add. You can check out the code here: http://dsource.org/projects/diamond/browser/trunk -- Best regards, Vladimir mailto:thecybershadow gmail.com
Sep 03 2008