diff -r 000000000000 -r 6474c204b198 tools/rb/find-leakers.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/rb/find-leakers.pl Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,62 @@ +#!/usr/bin/perl -w +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +use strict; + +my %allocs; +my %classes; +my %counter; + +LINE: while (<>) { + next LINE if (! /^ 0x01AFD3B8 1 AddRef 1 + + $allocs{$obj} = ++$counter{$class}; # the order of allocation + $classes{$obj} = $class; + } + elsif ($op eq 'Release' && $cnt == 0) { + # Example: 0x01AFD3B8 1 Release 0 + + delete($allocs{$obj}); + delete($classes{$obj}); + } + elsif ($op eq 'Ctor') { + # Example: 0x08880BD0 8 Ctor (20) + + $allocs{$obj} = ++$counter{$class}; + $classes{$obj} = $class; + } + elsif ($op eq 'Dtor') { + # Example: 0x08880BD0 8 Dtor (20) + + delete($allocs{$obj}); + delete($classes{$obj}); + } +} + + +sub sort_by_value { + my %x = @_; + sub _by_value($) { my %x = @_; $x{$a} cmp $x{$b}; } + sort _by_value keys(%x); +} + + +foreach my $key (&sort_by_value(%allocs)) { + # Example: 0x03F1D818 (2078) @ + print "$key (", $allocs{$key}, ") @ ", $classes{$key}, "\n"; +}