Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OutOfMemoryError heap dump

I have a java.lang.OutOfMemoryError:GC Overhead limit exceeded. There is no HeapDumpOnOutOfMemoryError command line option for my application. I need a heap dump but when I try to capture the dump with jmap or jcmd tools they are not responding:

jmap

D:\program>jmap -dump:live,format=b,file=d:\dump4.hprof 8280
Dumping heap to D:\dump4.hprof ...

jcmd

D:\program>jcmd 8280 GC.heap_dump d:\dump6.hprof
8280:

Processes are not completing but dump files are created. When I open them with VisualVM, they are loading infinitely.

If I capture a heap dump of e.g. VisualVM, Tools complete successfully and dumps are created and opened.

Could you please explain why jmap and jcmd are not completing? And how can I capture a dump of the application with OutOfMemoryError exception? Application is still working but there are only a few live threads.

like image 932
Dron4K Avatar asked Oct 21 '25 22:10

Dron4K


2 Answers

One possibility is that the heap size you intend to dump is too large in size. Please specify the size of the heap and RAM.

like image 164
Rohit Upadhyay Avatar answered Oct 24 '25 11:10

Rohit Upadhyay


It is not due to your intended heap size is more than allocated heap size. This error occurs when the JVM spent too much time performing Garbage Collection and was only able to reclaim very little heap space. Your application might have ended up using almost all the RAM and Garbage collector has spent too much time trying to clean it and failed repeatedly.

Your application's performance will be slow comparatively, This is because the CPU is using its entire capacity for Garbage Collection and hence cannot perform any other tasks.

Following questions need to be addressed:

  • What are the objects in the application that occupy large portions of the heap?
  • In which parts of the source code are these objects being allocated?

You can also use automated graphical tools such as JConsole which helps to detect performance problems in the code including java.lang.OutOfMemoryErrors.

like image 23
Kunal Avatar answered Oct 24 '25 10:10

Kunal



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!