Can I generate an HPROF file at will?
Asked Answered
L

4

33

I have a java process which is acting dubiously. I'd like to see what's up using the various HPROF analysis tools.

How do I generate one on the fly?

Lecythus answered 26/2, 2010 at 19:58 Comment(0)
B
60

Yes. You can generate an hprof file (containing heap memory usage) on the fly using the jmap tool, which ships with Sun's Java VM:

jmap -dump:file=<file_name> <pid>

Britney answered 19/3, 2010 at 16:35 Comment(1)
Thanks for the answer. Also, you can use jps to quickly find the pid of your Java process.Bodwell
H
7

You have to start the Java process with the correct arguments, which vary a little depending on the JVM version. Then, send a QUIT signal to the process to generate a new file.

The output is normally generated when the VM exits, although this can be disabled by setting the “dump on exit” option to “n” (doe=n). In addition, a profile is generated when Ctrl-\ or Ctrl-Break (depending on platform) is pressed. On Solaris OS and Linux a profile is also generated when a QUIT signal is received (kill -QUIT pid). If Ctrl-\ or Ctrl-Break is pressed multiple times, multiple profiles are generated to the one file.

Hindward answered 26/2, 2010 at 20:0 Comment(0)
T
0

VisualVM can help you dig into what your process is doing, including the ability to arbitrarily force a heap dump on a running process.

Travel answered 26/2, 2010 at 20:4 Comment(1)
Doesn't answer the question.Fleawort
T
0

jconsole now has the ability to create a dump to the app's current working directory.

  1. Connect to your JMX enabled instance
  2. Navigate to com.sun.management-->HotspotDiagnostic-->Operations
  3. Fill in p0 to name the Heap Dump
  4. press the heapDump button

Jconsole Screen Shot

Tychonn answered 13/7, 2016 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.