Beispiel #1
0
 private static void checkSunGC() throws Exception {
   // Test com.sun.management proxy
   List<GarbageCollectorMXBean> gcs = getGarbageCollectorMXBeans();
   for (GarbageCollectorMXBean gc : gcs) {
     ObjectName sunGc =
         new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + gc.getName());
     CompositeData cd = (CompositeData) server.getAttribute(sunGc, "LastGcInfo");
     if (cd != null) {
       System.out.println("GC statistic for : " + gc.getName());
       printGcInfo(cd);
     }
   }
 }
 /**
  * Prints the verbose GC log to System.out to list the memory usage of all memory pools as well as
  * the GC statistics.
  */
 public void printVerboseGc() {
   System.out.println("Uptime: " + formatMillis(rmbean.getUptime()));
   System.out.println("Heap usage: " + mmbean.getHeapMemoryUsage());
   System.out.println("Non-Heap memory usage: " + mmbean.getNonHeapMemoryUsage());
   for (GarbageCollectorMXBean gc : gcmbeans) {
     System.out.print(" [" + gc.getName() + ": ");
     System.out.print("Count=" + gc.getCollectionCount());
     System.out.print(" GCTime=" + formatMillis(gc.getCollectionTime()));
     System.out.print("]");
   }
   System.out.println();
   for (MemoryPoolMXBean p : pools) {
     System.out.print("  [" + p.getName() + ":");
     MemoryUsage u = p.getUsage();
     System.out.print(" Used=" + formatBytes(u.getUsed()));
     System.out.print(" Committed=" + formatBytes(u.getCommitted()));
     System.out.println("]");
   }
 }