我们的服务器报告了OutOfMemoryError的错误,服务器有一个32g的内存,而我们检查jvm参数,jvm参数如下:
-Xmx2048m -Xms2048m -Xmn768m -XX:PermSize=128m -Xss256k
当然,它太小了,那么,我想设置jvm参数的最佳做法是什么
答案 0 :(得分:0)
完全取决于您的应用程序服务器。例如: 对于tomcat,您需要修改tomcat的CATALINA_OPTS。
# CATALINA_OPTS (Optional) Java runtime options used when the "start",
# "run" or "debug" command is executed.
# Include here and not in JAVA_OPTS all options, that should
# only be used by Tomcat itself, not by the stop process,
# the version command etc.
# Examples are heap size, GC logging, JMX ports etc.
# JAVA_OPTS (Optional) Java runtime options used when any command
# is executed.
# Include here and not in CATALINA_OPTS all options, that
# should be used by Tomcat and also by the stop process,
# the version command etc.
# Most options should go into CATALINA_OPTS.
答案 1 :(得分:0)
最佳做法如下:
最终选择没有OutOfMemoryError的RAM值和较少诱导的GC暂停
答案 2 :(得分:0)
如果你想做一些"脏"调试,我建议使用
export _JAVA_OPTIONS="-Xmx2G -Xms1G -Xcheck:jni"
这些设置将由每个JVM
进行,可以"参见"这个变量。
有时,这是为您的应用找到最佳设置的最快捷方式。
然后,将首选设置放在适当的位置(取决于服务器)。