michael@0: #!/usr/bin/perl -w michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: use strict; michael@0: michael@0: my %allocs; michael@0: my %classes; michael@0: my %counter; michael@0: michael@0: LINE: while (<>) { michael@0: next LINE if (! /^ 0x01AFD3B8 1 AddRef 1 michael@0: michael@0: $allocs{$obj} = ++$counter{$class}; # the order of allocation michael@0: $classes{$obj} = $class; michael@0: } michael@0: elsif ($op eq 'Release' && $cnt == 0) { michael@0: # Example: 0x01AFD3B8 1 Release 0 michael@0: michael@0: delete($allocs{$obj}); michael@0: delete($classes{$obj}); michael@0: } michael@0: elsif ($op eq 'Ctor') { michael@0: # Example: 0x08880BD0 8 Ctor (20) michael@0: michael@0: $allocs{$obj} = ++$counter{$class}; michael@0: $classes{$obj} = $class; michael@0: } michael@0: elsif ($op eq 'Dtor') { michael@0: # Example: 0x08880BD0 8 Dtor (20) michael@0: michael@0: delete($allocs{$obj}); michael@0: delete($classes{$obj}); michael@0: } michael@0: } michael@0: michael@0: michael@0: sub sort_by_value { michael@0: my %x = @_; michael@0: sub _by_value($) { my %x = @_; $x{$a} cmp $x{$b}; } michael@0: sort _by_value keys(%x); michael@0: } michael@0: michael@0: michael@0: foreach my $key (&sort_by_value(%allocs)) { michael@0: # Example: 0x03F1D818 (2078) @ michael@0: print "$key (", $allocs{$key}, ") @ ", $classes{$key}, "\n"; michael@0: }