Friday, August 24, 2012

Creating Java dump file using jmap

This discussion would focus on how can we use jmap utility(bundled as part of standard jdk kit) to create java dumps. 

There could be couple of reasons why one would want to create a dump. Some of them are:-

  1. To Analyze the objects in heap and their impact on performance.
  2. To see how objects and classes are loaded.
  3. In case of OutOfMemoryError due to heap, we can see which objects are retaining the maximum chunk of heap etc.
Below is the command in the simple case:-

jmap -heap:format=b <pid>

where pid is the process-id of the jvm that runs your given java application.