#! /bin/sh
/usr/tools/gnu/bin/gawk '$1 == "new" {
	if ($3 == "Top") tag = $2 ":" $4;
	else tag = $2 ":" $3 ":" $4;
	where[$6] = tag;
	if (tag in siz) {
		if ($5 != siz[tag]) siz[tag] = "VAR";
	}
	else siz[tag] = $5;
}

$1 == "del" {
	if ($5 in where) {
		del[where[$5]] = "*";
		delete where[$5];
	}
	else printf("No new for %s\n", $0);
}
END {
	for (loc in where) {
		srcLine = where[loc];
		count[srcLine]++;
	}
	for (srcLine in count) {
		if (siz[srcLine] == "VAR") total = count[srcLine] "*VAR";
		else total = count[srcLine] * siz[srcLine];
		print total,srcLine,count[srcLine],siz[srcLine],del[srcLine];
	}
}' $MEMORYLOG | sort -nr

