0

I have a Spring Boot app (1.2.6) running on Oracle Linux with Tomcat embedded. Using java 1.7.0_45. It will run fine for 20 minutes to 2 hours. Then something either kills it or it self-destructs. I have a poor man's monitor to tell when it dies. Nothing useful appears in the application logback log file, other than a failure to release jdbc resources. Can I do anything to get Spring or Tomcat to tell me why it is stopping? Could a shutdown hook tell me why the java process is being terminated? I'm not using Spring Boot Actuator yet. What tools on linux could log a history of activity for a specific pid?

bwfrieds
  • 341
  • 3
  • 20
  • It could be Linux's out of memory killer. If it is, this question may be useful: http://stackoverflow.com/questions/726690/who-killed-my-process-and-why – Andy Wilkinson Oct 04 '15 at 21:43

2 Answers2

1

You likely want to use something like:

  • visualvm for monitoring the running JVM, or
  • jstack + jhat for analyzing the stack and heap at termination.

To get a heap dump at JVM shutdown (assuming it dies on OutOfMemoryError), add this to your JVM options:

-XX:+HeapDumpOnOutOfMemoryError
david.joyce13
  • 170
  • 1
  • 8
1

You could also try enabling Oracle's black box technology.

$JAVA_HOME/bin/java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=dumponexit=true,defaultrecording=true,dumponexitpath=/tmp/crash-data.jfr -jar my.jar

Obviously, you have to be running Oracle's JDK.

user1836542
  • 354
  • 1
  • 3
  • 9
  • So it died shortly after I exited my terminal session. The jfr file showed a SIGHUP event near the end. I guess using an ampersand on the end of the command line does not do what I expected. I'm still waiting for it to die again. When I restart it again, I'll try the "nohup" command. Memory usage seems to be stable at 64 MB. I doubt I have the liberty to create a service or add it to _init.d_, but I'll explore that option more later. – bwfrieds Oct 07 '15 at 20:34