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