我们在我们的项目 www.aerospaceresearch.net/constellation 中使用 Java,并直接从已卸载的 java bin 文件夹中使用 Java。
我们在操作系统甚至 32 位和 64 位版本之间对这个 java 的 ram 使用有所不同时遇到了一些麻烦。 是否可以为 ram 使用设置上限,以便 Java 对 ram 进行动态重新排列,例如它始终低于 150mb?
这确实可以帮助我们解决一些小问题,并将我们的应用带到 ram 功能有限的系统上。
提前致谢,安德烈亚斯
最佳答案
很难从你的问题中分辨出来,但你可能正在寻找 -Xmx
选项在 Sun 的 Oracle 的 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 实现,这些选项可能会有所不同;并注意上面结尾处的警告。
关于java - 限制 Java RAM 使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5927525/