首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

jvm虚拟机内存储器状态查看

2012-09-14 
jvm虚拟机内存状态查看jvm虚拟机内存状态查看import java.lang.Runtimepublic class Memory {public stat

jvm虚拟机内存状态查看

jvm虚拟机内存状态查看

import java.lang.Runtime;public class Memory {public static void main(String args[]) {System.out.println("usage:");Memory m = new Memory();long t = m.showUsage();System.out.println("Total:" + t + " Bytes");long fr = m.freeMemory();// System.gc();System.out.println("Free:" + fr + " Bytes");long rem = t - fr;System.out.println("Occupied Space :" + rem + " Bytes");Runtime run = Runtime.getRuntime();long max = run.maxMemory();long total = run.totalMemory();long free = run.freeMemory();long usable = max - total + free;System.out.println("最大内存 = " + max);System.out.println("已分配内存 = " + total);System.out.println("已分配内存中的剩余空间 = " + free);System.out.println("最大可用内存 = " + usable);}public long showUsage() {long l = Runtime.getRuntime().totalMemory();return (l);}public long freeMemory() {long f = Runtime.getRuntime().freeMemory();return (f);}}
?

热点排行