19

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.

Yuri
  • 4,254
  • 1
  • 29
  • 46
Dave
  • 15,639
  • 133
  • 442
  • 830
  • I think you need JDK, let us wait and see if anyone has other solution. – kosa Jun 13 '14 at 20:38
  • 1
    Beginning with jre 7, oracle provides a server-jre assembly which includes these tools. http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html – Brett Okken Jun 13 '14 at 20:43
  • Good to know. Unfrotunately upgrading our JRE is not an option at this time. – Dave Jun 13 '14 at 20:47
  • are you able to connect to your production environment through a JMX port? – eis Aug 22 '14 at 06:50

3 Answers3

17

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>

Jarek Przygódzki
  • 4,284
  • 2
  • 31
  • 41
9

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.

M A
  • 71,713
  • 13
  • 134
  • 174
  • I'm open to other tools other than jmap that can produce a heap dump. The thing is I would have to be able to run it from my home directory. – Dave Jun 13 '14 at 20:48
  • Maybe a third-party profiler would be useful here. Answer updated. – M A Jun 13 '14 at 21:17
0

The only way seems to be to zip your local SDK6 and put it somewhere on the server. Then open a remote console and from within the bin directory of that SDK dump the JRE.

If your client forbids uploading executable files, you are out of luck of course.

jhunovis
  • 698
  • 2
  • 10
  • 22