我在尝试将-XX:OnOutOfMemoryError="kill -9 %p"
命令传递到我的JVM参数时遇到了问题。
我正在使用Jetty7,并且将其放在start.ini文件中。启动时会给我下面的错误。这是使用jre / jre1.6.0_03l64时出现的错误:
Starting Jetty: STARTED Jetty Tue Apr 26 09:54:26 EDT 2011
Unrecognized option: -9
Could not create the Java virtual machine.
以下是start.ini文件的内容:
#===========================================================
# If the arguements in this file include JVM arguments
# (eg -Xmx512m) or JVM System properties (eg com.sun.???),
# then these will not take affect unless the --exec
# parameter is included or if the output from --dry-run
# is executed like:
# eval $(java -jar start.jar --dry-run)
#
# Below are some recommended options for Sun's JRE
#-----------------------------------------------------------
--exec
# -Dcom.sun.management.jmxremote
-Xmx4096m
-Xmn512m
-DLABEL=PROD_APP
-verbose:gc
-Xloggc:/export/opt/prod_app/logs/gc.log
-XX:OnOutOfMemoryError="kill -9 %p"
# -XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
# -XX:+PrintCommandLineFlags
# -XX:+DisableExplicitGC
# -XX:+UseConcMarkSweepGC
# -XX:ParallelCMSThreads=2
# -XX:+CMSClassUnloadingEnabled
# -XX:+UseCMSCompactAtFullCollection
# -XX:CMSInitiatingOccupancyFraction=80
如果注释掉这一行,jetty可以正常启动而没有任何问题。然而,由于系统存在内存泄漏的问题,我们确实需要添加此参数以防止进一步损害,如果我们的进程失败。
请问有人知道我在这里做错了什么,或者我如何解决这个问题吗?
-XX:OnOutOfMemoryError="<cmd args>;<cmd args>"
当首次抛出 OutOfMemoryError 时运行用户定义的命令。 (在1.4.2更新12、6中引入) http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html - eee