1 die "usage: perl memoryReport.pl [-c (sort by count) | -a (sort by allocated amount)] [-l] logFile.txt" if (@ARGV < 1 || $ARGV[0] eq "-h");
3 $sortMethod = 0; # 0 = using sort by allocated amount, 1 = sort by allocation count
26 return -($allocated{$a} <=> $allocated{$b});
31 return -($count{$a} <=> $count{$b});
38 if (/memory allocation/ || /memory leak/)
41 s/^.*unknown/unknown/;
44 s/\(.*\)// if (! $lines);
45 ($file, $size) = split;
46 $allocated{$file} += $size;
52 s/\(.*\)// if (! $lines);
53 ($file, $size) = split;
54 $allocated{$file} += $size;
61 # print sorted by allocated amount
62 foreach (sort sortAllocated
keys %allocated)
64 print $count{$_}, "\t", $allocated{$_}, "\t", $_, "\n";
69 # print sorted by # allocations
70 foreach (sort sortCount
keys %count)
72 print $count{$_}, "\t", $allocated{$_}, "\t", $_, "\n";