查看JVM內存使用情況


查看JVM內存使用情況

學習了:http://www.iteye.com/problems/54114

學習了:http://blog.csdn.net/neosmith/article/details/47753733

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); 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM