我可以自动重启tomcat jvm内存异常 [英] Can I auto restart tomcat jvm on out of memory exception

查看:433
本文介绍了我可以自动重启tomcat jvm内存异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这不是最佳做法,但我想知道如果我部署的应用程序抛出一个内存异常,我是否可以自动重启tomcat

I know that this is not "best practice" but I would like to know if I can auto restart tomcat if my deployed app throws an outofmemory exception

推荐答案

您可以尝试使用OnOutOfMemoryError JVM选项

You can try to use the OnOutOfMemoryError JVM option

-XX:OnOutOfMemoryError="/yourscripts/tomcat-restart"

还可以生成堆转储以供以后分析:

It is also possible to generate the heap dump for later analysis:

-XX:+HeapDumpOnOutOfMemoryError

小心结合这两个选项。如果强制在tomcat-restart中终止进程,则堆转储可能不完整。

Be careful with combining these two options. If you force killing the process in "tomcat-restart" the heap dump might not be complete.

这篇关于我可以自动重启tomcat jvm内存异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆