Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I generate an HPROF file at will?

Tags:

java

hprof

People also ask

How is Hprof file created?

An Hprof file can be created as a heap dump of the memory of a Java™ process. This is typically created when there is an Out of Memory error occurs on the system.

Where are Hprof files generated?

The only heap dump format generated by the -XX:+HeapDumpOnOutOfMemoryError option is the hprof binary format. The file will be generated in the home directory of the application (i.e. where the application is started) and the file owner will be the name of the application user.

What is a Hprof file?

hprof files are heap dump of the memory of java-based processes. Huge hprof files most commonly indicate out of memory issues about the related processes. These hprof files can be configured at startup to track and monitor memory performance issues.

Where is heap dump file created?

By default the heap dump is created in a file called java_pidpid. hprof in the working directory of the VM, as in the example above. You can specify an alternative file name or directory with the -XX:HeapDumpPath= option.


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>


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.