5

How can I trigger a heap dump for a Java 7 VM running on Linux without having a JDK installed?

In earlier versions of Java it was possible to set the -XX:+HeapDumpOnCtrlBreak JVM option and then trigger a heap dump by using kill -QUIT <pid>. I have been unable to get this to work with Java 7. Is there an equivalent to this without needing the JDK installed to get JVisualVM or jmap.

djechlin
  • 59,258
  • 35
  • 162
  • 290
Michael
  • 2,460
  • 3
  • 27
  • 47
  • Does `-XX:+HeapDumpOnOutOfMemoryError` work for you? http://www.oracle.com/technetwork/java/javase/clopts-139448.html#gbzrr – reprogrammer Nov 28 '12 at 22:29
  • As far as I am aware that still works (and we have it configured). We aren't actually getting to the point of running out of memory before our application is misbehaving. Therefore we would like to be able to trigger the heap dump on demand for analysis. – Michael Nov 28 '12 at 22:31
  • Do you get the error message `Unrecognized VM option 'HeapDumpOnCtrlBreak'`? – reprogrammer Nov 28 '12 at 22:36
  • `HeapDumpOnCtrlBreak` is not listed at http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html#DebuggingOptions – reprogrammer Nov 28 '12 at 22:38
  • can you manage to hook jvisualvm to the process? – irreputable Nov 28 '12 at 22:50
  • JVisualVM should work, but we want to be able to do this in a production environment where we do not have a JDK installed. – Michael Nov 29 '12 at 00:55

2 Answers2

0

VM option -XX:+HeapDumpOnCtrlBreak is no longer listed at http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html. So, I conclude that it's no longer supported.

From http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html:

Options that are specified with -XX are not stable and are subject to change without notice.

reprogrammer
  • 14,298
  • 16
  • 57
  • 93
  • Yeah, it definitely isn't supported anymore we got an error trying to specify it. I was hoping there was a similar way to get a heap dump in place of it. – Michael Nov 29 '12 at 00:54
0

You can generate a core dump with gcore, move it to another machine, and attach jmap to generate hprof file as described in Core dump taken with gcore, jmap conversion to hprof file format fails with Error message

See also accepted answer.

Community
  • 1
  • 1
fglez
  • 8,422
  • 4
  • 47
  • 78