#!/usr/bin/perl -w

my %strings;
my $count;

while (<>) {
    /^([\-\+])(.*)$/ || next; # ignore the 0.5% of multi-line lines etc.
    if ($1 eq '+') {
	$count = $strings{$2};
	$count = 0 if (!defined $count);
	$count = $count + 1;
	$strings{$2} = $count;
    } else { # -
	if (!defined $strings{$2}) {
#	    print STDERR "string '$2' freed but not allocated\n";
	} else {
	    $strings{$2} = $strings{$2} - 1;
	}
    }
}

my @content = sort { $strings{$b} <=> $strings{$a} } keys (%strings);
$count = @content;
print "$count live strings remain at end of log\n";
for my $str (@content) {
    print $strings{$str} . "\t$str\n";
}
