Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I produce a heap dump with only a JRE?

Tags:

java

heap-dump

We have a JRE installed on our production environment, but not a JDK. The versions of the JRE and OS are below.

[me@mymachine ~]$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
[me@mymachine ~]$ uname -a
Linux mymachine.mydomain.com 3.10.35-43.137.amzn1.x86_64 #1 SMP Wed Apr 2 09:36:59 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

It doesn’t appear as if the jmap tool is present anywhere on the system, and without root access, I’m not in a position to install it in any system location. What can I do to get a heap dump (i.e. produce a .hprof file)?

Also, we're using JBoss 7.1.3.AS if that matters.

like image 620
Dave Avatar asked Jun 13 '14 20:06

Dave


People also ask

Is Jstack part of JRE?

java - Why java8 server JRE do not contain server specific tools like jstack, jmap, jvisualvm, jstat - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

Why heap dump is not generated?

If the JVM argument is passed to JVM and no heap dump got generated then it implies the application yet to suffer OutOfMemory condition.


2 Answers

Use jattach, a tool created by JVM hacker Andrei Pangin. It's tiny (24KB), works with just JRE and supports Linux containers.

jattach PID-OF-JAVA dumpheap <path to heap dump file>

like image 180
Jarek Przygódzki Avatar answered Oct 13 '22 01:10

Jarek Przygódzki


Built-in tools like jmap, jconsole, and jvisualvm are only available in a JDK. Another option is to add the VM argument -XX:+HeapDumpOnOutOfMemoryError which tells the JVM to automatically generate a heap dump when an OutOfMemoryError occurs, and the argument -XX:HeapDumpPath to specify the path for the heap dump.

If you cannot upgrade your JRE to use tools like the ones in the server JRE 7 (http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html), you may have to consider third-party profiling tools like JProfiler or ones list here.

like image 42
M A Avatar answered Oct 13 '22 03:10

M A