1 Subject: [nasm-devel] tool to help find memory leaks
2 Date: Fri, 02 Nov 2001 22:08:01 -0500
3 From: Ed Beroset <beroset@mindspring.com>
4 Reply-To: nasm-devel@yahoogroups.com
5 To: nasm-devel@yahoogroups.com
7 Here's a little Perl script I wrote a while ago to help track down memory
8 leaks in nasm. First, compile nasm with LOGALLOC defined (see
9 nasmlib.c). That creates a log file of all allocs and frees. This Perl
10 script reads that file and tells you which source code lines caused a leak
11 (or a free of unallocated memory). There are many leaks, almost all of
12 them in the preprocessor.
14 -+--- findleak.pl begins
20 if (/realloc\((0x[0-9a-f]+).*\).*returns \((0x[0-9a-f]+)/)
24 print "free before alloc! $_";
27 print "memory leak! $_";
32 elsif (/free\((0x[0-9a-f]+)/)
36 print "free before alloc! $_";
39 elsif (m/returns (0x[0-9a-f]+)/)
42 print "memory leak! $_";
48 foreach $goo (sort keys %mem)
52 print "$mem{$goo} $alloc{$goo}";
55 -+--- findleak.pl ends
59 Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/