64位系统上可以给32位Jvm分配多少内存
public class MaxMemory {
public static void main(String[] args) {
Runtime rt = Runtime.getRuntime();
long totalMem = rt.totalMemory();
long maxMem = rt.maxMemory();
long freeMem = rt.freeMemory();
double megs = 1048576.0;
//总内存
System.out.println ("Total Memory: " + totalMem + " (" + (totalMem/megs) + " MiB)");
//最大分配内存
System.out.println ("Max Memory: " + maxMem + " (" + (maxMem/megs) + " MiB)");
//空闲内存
System.out.println ("Free Memory: " + freeMem + " (" + (freeMem/megs) + " MiB)");
}
}
Loading...