java怎么取得当前JAVA系统运行中实时的内存的使用率
我有一个JAVA做的应用系统,我想在这个系统运行期间,取得本系统当前占用的内存,还有取得本系统还剩多少可用内存,系统一启动,默认分配64M的可用内存.
谢谢大家,急.
[解决办法]
Runtime rt=Runtime.getRuntime();
System.out.println( "Total Memory= "+ rt.totalMemory()+ " Free Memory = "+rt.freeMemory());
查看下文档Class Runtime的说明
[解决办法]
<%
long endMem = Runtime.getRuntime().freeMemory();
long total= Runtime.getRuntime().maxMemory();
out.println( "Total Memory: "+total);
out.println( "Start Memory: "+startMem);
out.println( "End Memory: "+endMem);
out.println( "Use memory: "+ (startMem - endMem));
long endTime = System.currentTimeMillis();
out.println( "Use Time: "+ (endTime-startTime));
%>
[解决办法]
lz看得比较深,我也想知道