Search code examples
javamemorymemory-leaksjmap

Is a JVM stopped while executing jmap?


Does my java application continue running while jmap is taking its memory dump?


Solution

  • Your application is stopped. The only practical way to get an accurate heap dump would be to stop all application activity while the dump is being created.

    Whether this is a "brief" pause or a "long" pause depends on how much is dumped. If you use "-dump" then you will dump the entire heap, including unreachable objects. If you use "-dump:live" you will only dump reachable objects ... but that also entails (at least) marking the heap to figure out which objects are reachable.

    But if you are dumping a gigabyte sized heap, expect the pause time to be measured in minutes rather than seconds.


    Re the suggestion that you could avoid stopping the JVM by using fork, it turns out that forking a multi-threaded process can be problematic:

    Then there is is the resource usage issue.