Can I auto restart tomcat jvm on out of memory exception

后端 未结 7 1760
北海茫月
北海茫月 2021-01-31 05:12

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

7条回答
  •  终归单人心
    2021-01-31 05:37

    Generally, no. The VM is a bad state, and cannot be completely trusted.

    Typically, one can use a configurable wrapper process that starts and stops the "real" server VM you want. An example I've worked with is "Java Service Wrapper" from Tanuki Software http://wrapper.tanukisoftware.com/doc/english/download.jsp

    I know there are others.

    To guard against OOMs in the first place, there are ways to instrument modern VMs via interface beans to query the status of the heap and other memory structures. These can be used to, say, warn in a log or an email if some app specific operations are pushing some established limits.

提交回复
热议问题