public class RuntimeTest
{
public static void main(String args[])
{
Runtime rtime = Runtime.getRuntime();
long totalMemory = rtime.totalMemory()/1024;
long freeMemory = rtime.freeMemory()/1024;
System.out.println("totalMemory: " + totalMemory + "k");
System.out.println("freeMemory: " + freeMemory+ "k");
}
}
程序运行结果为:
totalMemory: 1984k
freeMemory: 1734k |
|