20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 27 /* 28 * The Original Code is HAT. The Initial Developer of the 29 * Original Code is Bill Foote, with contributions from others 30 * at JavaSoft/Sun. 31 */ 32 33 package com.sun.tools.hat.internal.server; 34 35 import com.sun.tools.hat.internal.model.*; 36 import java.util.*; 37 38 public class FinalizerSummaryQuery extends QueryHandler { 39 public void run() { 40 Enumeration objs = snapshot.getFinalizerObjects(); 41 startHtml("Finalizer Summary"); 42 43 out.println("<p align='center'>"); 44 out.println("<b><a href='/'>All Classes (excluding platform)</a></b>"); 45 out.println("</p>"); 46 47 printFinalizerSummary(objs); 48 endHtml(); 49 } 50 51 private static class HistogramElement { 52 public HistogramElement(JavaClass clazz) { 53 this.clazz = clazz; 54 } 55 56 public void updateCount() { 57 this.count++; 58 } 59 60 public int compare(HistogramElement other) { 61 long diff = other.count - count; 62 return (diff == 0L)? 0 : ((diff > 0L)? +1 : -1); 63 } 64 65 public JavaClass getClazz() { 66 return clazz; 67 } 68 69 public long getCount() { 70 return count; 71 } 72 73 private JavaClass clazz; 74 private long count; 75 } 76 77 private void printFinalizerSummary(Enumeration objs) { 78 int count = 0; 79 Map<JavaClass, HistogramElement> map = new HashMap<JavaClass, HistogramElement>(); 80 81 while (objs.hasMoreElements()) { 82 JavaHeapObject obj = (JavaHeapObject) objs.nextElement(); 83 count++; 84 JavaClass clazz = obj.getClazz(); 85 if (! map.containsKey(clazz)) { 86 map.put(clazz, new HistogramElement(clazz)); 87 } 88 HistogramElement element = map.get(clazz); 89 element.updateCount(); 90 } 91 92 out.println("<p align='center'>"); 93 out.println("<b>"); 94 out.println("Total "); 95 if (count != 0) { 96 out.print("<a href='/finalizerObjects/'>instances</a>"); 97 } else { | 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 27 /* 28 * The Original Code is HAT. The Initial Developer of the 29 * Original Code is Bill Foote, with contributions from others 30 * at JavaSoft/Sun. 31 */ 32 33 package com.sun.tools.hat.internal.server; 34 35 import com.sun.tools.hat.internal.model.*; 36 import java.util.*; 37 38 public class FinalizerSummaryQuery extends QueryHandler { 39 public void run() { 40 Enumeration<?> objs = snapshot.getFinalizerObjects(); 41 startHtml("Finalizer Summary"); 42 43 out.println("<p align='center'>"); 44 out.println("<b><a href='/'>All Classes (excluding platform)</a></b>"); 45 out.println("</p>"); 46 47 printFinalizerSummary(objs); 48 endHtml(); 49 } 50 51 private static class HistogramElement { 52 public HistogramElement(JavaClass clazz) { 53 this.clazz = clazz; 54 } 55 56 public void updateCount() { 57 this.count++; 58 } 59 60 public int compare(HistogramElement other) { 61 long diff = other.count - count; 62 return (diff == 0L)? 0 : ((diff > 0L)? +1 : -1); 63 } 64 65 public JavaClass getClazz() { 66 return clazz; 67 } 68 69 public long getCount() { 70 return count; 71 } 72 73 private JavaClass clazz; 74 private long count; 75 } 76 77 private void printFinalizerSummary(Enumeration<?> objs) { 78 int count = 0; 79 Map<JavaClass, HistogramElement> map = new HashMap<JavaClass, HistogramElement>(); 80 81 while (objs.hasMoreElements()) { 82 JavaHeapObject obj = (JavaHeapObject) objs.nextElement(); 83 count++; 84 JavaClass clazz = obj.getClazz(); 85 if (! map.containsKey(clazz)) { 86 map.put(clazz, new HistogramElement(clazz)); 87 } 88 HistogramElement element = map.get(clazz); 89 element.updateCount(); 90 } 91 92 out.println("<p align='center'>"); 93 out.println("<b>"); 94 out.println("Total "); 95 if (count != 0) { 96 out.print("<a href='/finalizerObjects/'>instances</a>"); 97 } else { |