I’m trying to find the cause of memory leaks in my java application. I need to get a heap dump for a process that is in a long GC-cycle. Jmap isn’t working in this case both because app is hanged and because heap is very large.
Unfortunately, jmap throws UnknownOopException on the core dump I took. I suppose that it isn’t correct to take core dump during GC. Is there any way to suspend java process at the point where taking core dump will be correct?
Or am I totally wrong and got broken core dump because of some other problem?
You cannot take a heap dump while a GC is being performed. You need to take a heap dump before or after the GC. If you want to know why it is taking so long it is usueful to determine which pahse is taking so long. To see this to add
-verbosegcThis will indicate if it is taking a long time to reach a safe point, copy objects, scan the tenrured space, check references or something else.It could be taking along time because you have lots of objects to clean up. As a guessimate it can take about a worst case 1 second per 2 GB of heap objects.