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