import java.io.*;
public class Foo {
public static void main(String[] _args) {
System.out.println("free:" + Runtime.getRuntime().freeMemory() +
". max:" + Runtime.getRuntime().maxMemory());
}
}
使用上述程序,
C:\Users\Administrator\Desktop>javac Foo.java
C:\Users\Administrator\Desktop>java Foo -Xms2000000000m -Xmx200000000000m
free:15519000. max:259522560
C:\Users\Administrator\Desktop>java Foo -Xms2g -Xmx2g
free:15519000. max:259522560
C:\Users\Administrator\Desktop>java Foo -Xms3g -Xmx3g
free:15609440. max:259522560
C:\Users\Administrator\Desktop>java Foo -Xms1g -Xmx1g
free:15519000. max:259522560
C:\Users\Administrator\Desktop>java Foo -Xmx1k -Xmx2k
free:15609440. max:259522560
似乎没有任何改变,而我现在需要充足的额外记忆。我做错了什么?我目前正在使用Oracle jdk。