tools/rb/find-leakers.pl
author B2G Bumper Bot <release+b2gbumper@mozilla.com>
Thu, 03 Jul 2014 01:25:25 -0700
changeset 205896 8c6d2ef269cd87cb34d6a46ca2fd9490712a8033
parent 96742 f4157e8c410708d76703f19e4dfb61859bfe32d8
permissions -rwxr-xr-x
Bumping gaia.json for 4 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/f98cc089db06 Author: Jose M. Cantera <jmcanterafonseca@gmail.com> Desc: Merge pull request #20613 from jmcanterafonseca/contacts_Data Bug 989929 - [Contacts][Refactor] Create Contacts indexed DB library to ... ======== https://hg.mozilla.org/integration/gaia-central/rev/5e71e90bb54f Author: José Manuel Cantera <jmcanterafonseca@gmail.com> Desc: Bug 989929 - [Contacts][Refactor] Create Contacts indexed DB library to support synchronization from the Global Contacts Datastore ======== https://hg.mozilla.org/integration/gaia-central/rev/7fb5ac42a379 Author: Greg Weng <snowmantw@gmail.com> Desc: Merge pull request #21317 from snowmantw/issue1033135 Bug 1033135 - [System] Hide SIM pin dialog if the screen unlock into Cam... ======== https://hg.mozilla.org/integration/gaia-central/rev/487e7faa8395 Author: Greg Weng <snowmantw@gmail.com> Desc: Bug 1033135 - [System] Hide SIM pin dialog if the screen unlock into Camera app

#!/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 (! /^</);

    my @fields = split(/ /, $_);
    my $class = shift(@fields);
    my $obj   = shift(@fields);
    my $sno   = shift(@fields);
    my $op    = shift(@fields);
    my $cnt   = shift(@fields);

    # for AddRef/Release $cnt is the refcount, for Ctor/Dtor it's the size

    if ($op eq 'AddRef' && $cnt == 1) {
        # Example: <nsStringBuffer> 0x01AFD3B8 1 AddRef 1

        $allocs{$obj} = ++$counter{$class}; # the order of allocation
        $classes{$obj} = $class;
    }
    elsif ($op eq 'Release' && $cnt == 0) {
        # Example: <nsStringBuffer> 0x01AFD3B8 1 Release 0

        delete($allocs{$obj});
        delete($classes{$obj});
    }
    elsif ($op eq 'Ctor') {
        # Example: <PStreamNotifyParent> 0x08880BD0 8 Ctor (20)

        $allocs{$obj} = ++$counter{$class};
        $classes{$obj} = $class;
    }
    elsif ($op eq 'Dtor') {
        # Example: <PStreamNotifyParent> 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) @ <nsStringBuffer>
    print "$key (", $allocs{$key}, ") @ ", $classes{$key}, "\n";
}