blob: 35c07168bee45ca67ddea62f76dcd0e52bbf5d24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/usr/bin/perl
#
# Summarizes output from memtrace using a set of heuristics
#
sub process_stdin() {
my %leaks = ();
my $total_bytes = 0;
while(<STDIN>) {
my $line = $_;
chomp($line);
my $bytes, $loc;
($bytes, $loc) = ($line =~ m/[ \t]*([0-9]*)[ \t]*[0-9\.%]*[ \t]*(.*)/);
my $location_blame = "";
# print "Found: $bytes, $loc\n";
$total_bytes += $bytes;
if ($loc =~ m/v8/) {
$location_blame = "v8";
} elsif ($loc =~ m/sqlite/) {
$location_blame = "sqlite";
} elsif ($loc =~ m/SkBitmap/) {
$location_blame = "skia";
} elsif ($loc =~ m/disk_cache/) {
$location_blame = "disk cache";
} elsif ($loc =~ m/skia/) {
$location_blame = "skia";
} elsif ($loc =~ m/:WSA/) {
$location_blame = "net";
} elsif ($loc =~ m/dns/) {
$location_blame = "net";
} elsif ($loc =~ m/trunk\\net/) {
$location_blame = "net";
} elsif ($loc =~ m/WinHttp/) {
$location_blame = "WinHttp";
} elsif ($loc =~ m/:I_Crypt/) {
$location_blame = "WinHttpSSL";
} elsif ($loc =~ m/CryptGetTls/) {
$location_blame = "WinHttpSSL";
} elsif ($loc =~ m/WinVerifyTrust/) {
$location_blame = "WinHttpSSL";
} elsif ($loc =~ m/Cert/) {
$location_blame = "WinHttpSSL";
} elsif ($loc =~ m/plugin/) {
$location_blame = "plugin";
} elsif ($loc =~ m/NP_/) {
$location_blame = "plugin";
} elsif ($loc =~ m/hunspell/) {
$location_blame = "hunspell";
} elsif ($loc =~ m/decoder/) {
$location_blame = "img decoder";
} elsif ($loc =~ m/TextCodec/) {
$location_blame = "fonts";
} elsif ($loc =~ m/glyph/) {
$location_blame = "fonts";
} elsif ($loc =~ m/cssparser/) {
$location_blame = "webkit css";
} elsif ($loc =~ m/::CSS/) {
$location_blame = "webkit css";
} elsif ($loc =~ m/Arena/) {
$location_blame = "webkit arenas";
} elsif ($loc =~ m/IPC/) {
$location_blame = "ipc";
} elsif ($loc =~ m/trunk\\chrome\\browser/) {
$location_blame = "browser";
} elsif ($loc =~ m/trunk\\chrome\\renderer/) {
$location_blame = "renderer";
} elsif ($loc =~ m/webcore\\html/) {
$location_blame = "webkit webcore html";
} elsif ($loc =~ m/webkit.*string/) {
$location_blame = "webkit strings";
} elsif ($loc =~ m/htmltokenizer/) {
$location_blame = "webkit HTMLTokenizer";
} elsif ($loc =~ m/javascriptcore/) {
$location_blame = "webkit javascriptcore";
} elsif ($loc =~ m/webkit/) {
$location_blame = "webkit other";
# print "$location_blame: ($bytes) $loc\n";
} else {
$location_blame = "unknown";
# print "$location_blame: ($bytes) $loc\n";
}
# surface large outliers
if ($bytes > 1000000 && $location_blame eq "unknown") {
$location_blame = $loc;
}
$leaks{$location_blame} += $bytes;
}
# now dump our hash table
my $sum = 0;
my @keys = keys(%leaks);
for ($i=0; $i<@keys; $i++) {
my $key = @keys[$i];
printf "%8d\t%3.2f%%\t%s\n", $leaks{$key}, (100* $leaks{$key} / $total_bytes), $key;
$sum += $leaks{$key};
}
print("TOTAL: $sum\n");
}
# ----- Main ------------------------------------------------
process_stdin();
|