限制Java RAM的使用?

And*_*nig 1 java ram limit option

我们将Java用于我们的项目www.aerospaceresearch.net/constellation,并从未安装的java bin文件夹中直接使用Java.

我们在使用这种java的ram时遇到了一些麻烦,不同的是操作系统甚至是32位和64位版本.是否可以设置ram使用的上限,以便Java对ram进行动态重新排列,例如它总是低于150mb?

这将真正帮助我们解决一些小问题,并将我们的应用程序带到具有有限ram功能的系统.

提前谢谢,安德烈亚斯

T.J*_*der 7

从你的问题很难说,但你可能正在寻找Sun的 Oracle 工具中的-Xmx选项,该工具设置了Java内存堆的最大大小.java

有关该版本java工具提供的各种非标准功能(包括与堆相关的几个)的详细信息,请java -X在命令提示符下键入.对于我安装的版本,这给了我:

java -X
    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by :>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by :>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by :>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni       perform additional checks for JNI functions
    -Xshare:off       do not attempt to use shared class data
    -Xshare:auto      use shared class data if possible (default)
    -Xshare:on        require using shared class data, otherwise fail.

The -X options are non-standard and subject to change without notice.

如果您使用的是不同的Java实现,那么这些选项可能会有所不同; 并注意上面结尾处的警告.