Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GC overhead limit Exception : Unable to take threads & heap dump

We are facing GC overhead limit Exception on our servers and we are unable to take heap and thread dump , as it is giving some exception. How to go about solving this issue ? Can some one please help here .

like image 243
Sahil Gupta Avatar asked Jan 21 '26 03:01

Sahil Gupta


1 Answers

Normal way of taking heap and thread dump relies JMX and so called VM operations.

GC is itself a VM operation, so until it is finished next VM operation cannot start (and JMX is implement in Java so it is also blocked as a part of Stop-the-World pause).

You can try using -F option far jstack and jmap commands in JDK pause. Forced mode is using OS debug capabilities to access JVM process memory and does not require "cooperation" from JVM process.

Another useful option is jmap -J-Dsun.tools.attach.attachTimeout=120000 ... which would increase timeout for jmap to wait for JVM to respond.

-XX:+HeapDumpOnOutOfMemoryError is another option if JVM is actually crashing with OOME.

-XX:HeapDumpPath=filename option would allow you to control path to generated heap dump.

Both flags are amendable at runtime with jinfo. For example.

jinfo -flag +HeapDumpOnOutOfMemoryError <PID>
jinfo -flag HeapDumpPath=mydump.hprof <PID>

Finally, you can take OS specific core dump, then use jstack or jmap pointing to core dump to convert it to Java format.

like image 109
Alexey Ragozin Avatar answered Jan 22 '26 17:01

Alexey Ragozin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!