如何为 Java (xmx)、Linux (centos) 设置默认最大堆大小
我的服务器上有许多小型 java 程序在 crons 中运行。我有一个 openvz VPS,java 对于内存和 openvz 来说非常有问题。
到目前为止,我提出的最好的解决方案是运行我的程序:
java -Xmx16m class
这工作正常,但是我有很多程序正在运行,并且我想为所有系统设置默认的最大堆,这样我就不会更改所有的启动编写脚本,而不必每次编写新脚本时都记得这样做。
我尝试找到一种方法来设置/更改我的 CentOS 系统的全局默认值,但我没有运气!
如果有人能帮助我,我将不胜感激。
谢谢。
I have many small java programs running in crons in my server. I have an openvz VPS, and java is very poblematic with memory and openvz.
The best solution i have come up so far is running my programs with:
java -Xmx16m class
This works ok, but I have many programs running, and i want to set the default maximum heap for all the system, so that i don't change all the start up scripts, and not have to remember to do that every time i write a new one.
I tried finding a way to set/change a global default value for my CentOS system, but i had no luck with that!
I would appreciate if someone could help me.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试将其添加到您的 shell 配置文件中
export _JAVA_OPTIONS=-Xmx16m
这可能有效也可能无效,具体取决于您运行的 JVM。
You could try adding this to your shell profile
export _JAVA_OPTIONS=-Xmx16m
This may or may not work depending on what JVM you are running.
创建一个环境变量
_JAVA_OPTIONS
并在其中设置新值。那应该有效Create an environment variable
_JAVA_OPTIONS
and set the new value there. That should work