打印当前系统内存使用情况

打印当前系统内存使用情况

private void showMemoryUsage() {
Runtime runtime = Runtime.getRuntime();
long free = runtime.freeMemory();
long total = runtime.totalMemory();
long used = total - free;

long totalMB = total / (1024 * 1024);
long usedMB = used / (1024 * 1024);
LOG.debug("Memory usage: " + usedMB + " of " + totalMB + "M");
}

 

posted @ 2021-06-14 15:00  xiluhua  阅读(161)  评论(0)    收藏  举报