Date: Thu, 7 Apr 2005 13:59:17 -0400 From: Charles Swiger <cswiger@mac.com> To: Sebastien Poirier <spoirier@BEENOX.COM> Cc: barner@FreeBSD.org Subject: Re: FreeBSD Port: valgrind-snapshot-352_3 Message-ID: <bdec7cedde67a688d0b96d573598edfb@mac.com> In-Reply-To: <27B2E82614CBB44BB1E8767F89247B710B7013@srv-sbs2003.BEENOX.COM> References: <27B2E82614CBB44BB1E8767F89247B710B7013@srv-sbs2003.BEENOX.COM>
next in thread | previous in thread | raw e-mail | index | archive | help
On Apr 6, 2005, at 1:20 PM, Sebastien Poirier wrote: > I would like to know if your port is aimed for Mac OS X too. > We are looking for a memory debug tools for Mac OS X and Valgrind > seems to be the best for this purpose. Hi, Sebastian-- The "leaks" command which comes with OS X is pretty darn useful: % cat /tmp/foo.c #include <stdlib.h> void bad(int size) { int x; char *leaky; leaky = malloc(size); for (x = 0; x < size; x++) leaky[x] = (char) x + 'a'; leaky = NULL; } main() { bad(10); bad(20); sleep(100); } % MallocStackLogging=1 /tmp/foo & malloc[16451]: recording stacks using standard recorder % leaks foo Process 16451: 10 nodes malloced for 1 KB Process 16451: 2 leaks for 48 total leaked bytes. Leak: 0x00100150 size=32 string 'abcdefghijklmnopqrst' Call stack: [thread 1a27]: | 0x0 | start | _start | main | bad | malloc | malloc_zone_malloc Leak: 0x00100140 size=16 string 'abcdefghij' Call stack: [thread 1a27]: | 0x0 | start | _start | main | bad | malloc | malloc_zone_malloc Even if you don't run with that ENV variable set, simply seeing the size and the contents of leaked memory is often enough to help ("do you know how big your structures are?" :-), but having the call stack responsible for the allocation of the memory is a godsend. -- -Chuck
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bdec7cedde67a688d0b96d573598edfb>