From 63f57157e1626f0e20204331e068917e5c5b682c Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Sat, 2 Sep 2000 03:29:30 +0000 Subject: [PATCH] [not part of build] moved Type and StringTable classes to separate files. Changed printHistogram() to include product {count * size} for each bin. --- gc/boehm/leaksoup/leaksoup.java | 63 +++++---------------------------- 1 file changed, 9 insertions(+), 54 deletions(-) diff --git a/gc/boehm/leaksoup/leaksoup.java b/gc/boehm/leaksoup/leaksoup.java index 88bf3de04b18..b1f78145578f 100644 --- a/gc/boehm/leaksoup/leaksoup.java +++ b/gc/boehm/leaksoup/leaksoup.java @@ -37,39 +37,6 @@ import java.io.*; import java.util.*; -class Type { - String mName; - int mSize; - - Type(String name, int size) { - mName = name; - mSize = size; - } - - public int hashCode() { - return mName.hashCode() + mSize; - } - - public boolean equals(Object obj) { - if (obj instanceof Type) { - Type t = (Type) obj; - return (t.mSize == mSize && t.mName.equals(mName)); - } - return false; - } - - public String toString() { - return "<" + mName + "> (" + mSize + ")"; - } - - static class Comparator implements QuickSort.Comparator { - public int compare(Object obj1, Object obj2) { - Type t1 = (Type) obj1, t2 = (Type) obj2; - return (t1.mSize - t2.mSize); - } - } -} - class Leak { String mAddress; Type mType; @@ -176,19 +143,6 @@ final class LineReader { } } -class StringTable { - private Hashtable strings = new Hashtable(); - - public String intern(String str) { - String result = (String) strings.get(str); - if (result == null) { - result = str; - strings.put(str, str); - } - return result; - } -} - public class leaksoup { private static boolean ROOTS_ONLY = false; @@ -353,6 +307,7 @@ public class leaksoup { } // print the object histogram report. + out.println("

Leak Histogram:

"); printHistogram(out, hist); // open original file again, as a RandomAccessFile, to read in stack crawl information. @@ -388,17 +343,17 @@ public class leaksoup { } static void printHistogram(PrintWriter out, Histogram hist) throws IOException { - // sort the objects by histogram count. - Object[] objects = hist.objects(); + // sort the types by histogram count. + Object[] types = hist.objects(); QuickSort sorter = new QuickSort(new HistComparator(hist)); - sorter.sort(objects); + sorter.sort(types); - out.println("

Leak Histogram:

"); out.println("
");
-		int count = objects.length;
-		while (count > 0) {
-			Object object = objects[--count];
-			out.println(object.toString() + " : " + hist.count(object));
+		int index = types.length;
+		while (index > 0) {
+			Type type = (Type) types[--index];
+			int count = hist.count(type);
+			out.println(type.toString() + " : " + count + " {" + (count * type.mSize) + "}");
 		}
 		out.println("
"); }