简体   繁体   中英

Acquiring heap dump from a Java process to debug memory leaks

Followed the below process but I'm unable to analyze the dump generated.

  1. I tried to get heap dump from the Java process running on Linux box using "jmap -F -dump:format=b,file=/tmp/test.hprof "
  2. Ctrl+C after a span of 60 seconds
  3. Heap dump generated from above step is launched using Eclipse MAT (Memory Analyzer Tool), but I see the following error.

An internal error occurred during: "Parsing heap dump from '/users/sobhan/Test.hprof'". java.lang.NullPointerException

PS: I tried other analyzer tools like VisualVM, IBM Heap Analyzer and the result is same. I think the heap dump was corrupted (Does using Ctrl+C is faulty here ?). If so, please suggest the correct way lo gracefully exit 'jmap'

Thanks in advance.

You need to wait for the heap dump to complete. Based on the size of the heap it may take few seconds to several minutes. At least once, it took 20 minutes for me (Size of the dump was around 10G if I remember correctly). You may try "-dump:live" option, that will dump only the live objects and no garbage.

jmap -F -dump:live,format=b,file=<file_name.hprof> <rdu_process_id>

However, you may be encountering this issue as well?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM