public static MemoryUsage getHeapMemoryUsage() {
return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
}
public static LocalMemoryStats getMemoryStats() {
LocalMemoryStatsImpl stats = new LocalMemoryStatsImpl();
stats.setTotalPhysical(totalPhysicalMemory());
stats.setFreePhysical(freePhysicalMemory());
MemoryUsage memoryUsage = getHeapMemoryUsage();
stats.setMaxHeap(memoryUsage.getMax());
stats.setCommittedHeap(memoryUsage.getCommitted());
stats.setUsedHeap(memoryUsage.getUsed());
stats.setCommittedNativeMemory(LocalInstanceStats.STAT_NOT_AVAILABLE);
stats.setMaxNativeMemory(LocalInstanceStats.STAT_NOT_AVAILABLE);
stats.setUsedNativeMemory(LocalInstanceStats.STAT_NOT_AVAILABLE);
stats.setFreeNativeMemory(LocalInstanceStats.STAT_NOT_AVAILABLE);
stats.setGcStats(GCStatsSupport.getGCStats());
return stats;
}