//get all the info and pretty print it duration = //System.out.println("GcInfo CompositeType: " + info.getGcInfo().getCompositeType()); //System.out.println("GcInfo MemoryUsageAfterGc: " + info.getGcInfo().getMemoryUsageAfterGc()); //System.out.println("GcInfo MemoryUsageBeforeGc: " + info.getGcInfo().getMemoryUsageBeforeGc()); //Get the information about each memory space, and pretty print it Map membefore = info.getGcInfo().getMemoryUsageBeforeGc(); Map mem = info.getGcInfo().getMemoryUsageAfterGc(); for (Entry entry : mem.entrySet()) { String name = entry.getKey(); MemoryUsage memdetail = entry.getValue(); long memInit = memdetail.getInit(); long memCommitted = memdetail.getCommitted(); long memMax = memdetail.getMax(); long memUsed = memdetail.getUsed(); MemoryUsage before = membefore.get(name); long beforepercent = ((before.getUsed() * 1000L) / before.getCommitted()); long percent = ((memUsed * 1000L) / before.getCommitted()); //>100% when it gets expanded System.out.print(name + (memCommitted == memMax ? "(fully expanded)" : "(still expandable)") + "used: " + (beforepercent / 10) + "." + (beforepercent % 10) + "%->" + (percent / 10) + "." + (percent % 10) + "%(" + ((memUsed / 1048576) + 1) + "MB) / "); } System.out.println(); totalGcDuration += info.getGcInfo().getDuration(); long percent = totalGcDuration * 1000L / info.getGcInfo().getEndTime(); System.out.println("GC cumulated overhead " + (percent / 10) + "." + (percent % 10) + "%");