查看JVM内存使用情况

Runtime run = Runtime.getRuntime(); 

long max = run.maxMemory()/(1024*1024); 

long total = run.totalMemory()/(1024*1024); 

long free = run.freeMemory()/(1024*1024); 

long usable = max - total + free; 

System.out.println("最大内存 = " + max); 
System.out.println("已分配内存 = " + total); 
System.out.println("已分配内存中的剩余空间 = " + free); 
System.out.println("最大可用内存 = " + usable); 

posted on 2018-07-24 20:44  范兵  阅读(2319)  评论(0编辑  收藏  举报

导航