Thursday 28 January 2016

java.lang.OutOfMemoryError: GC overhead limit exceeded

Hello Everyone,

Last time we discussed the issue of java.lang.OutOfMemoryError: Java heap space for Apache Tomcat server. Similarly today we are having another JVM related issue for WebSphere application server. Here my users are complaining about the some kind of slowness while application access and when I check for the error I am getting below error string in logs.

Error:


java.lang.OutOfMemoryError: GC overhead limit exceeded

Cause:


Before solution we need to know what is GC and why we are getting this error called  GC overhead limit exceeded.
Java runtime environment contains a built-in Garbage Collection (GC)  daemon process. Whenever a particular space in memory is no longer used, a process called Garbage Collection clears that memory space and GC do this work on regular basis. There are different algorithms and parameter of GC which defines how GC will work. And if in case GC is not performing well the it will write the error code similar to what we get.

The java.lang.OutOfMemoryError: GC overhead limit exceeded error is displayed when your application has exhausted pretty much all the available memory and GC has repeatedly failed to clean it. The java.lang.OutOfMemoryError: GC overhead limit exceeded error is the JVM’s way of signaling that your application spends too much time doing garbage collection with too little result. By default the JVM is configured to throw this error if it spends more than 98% of the total time doing GC and when after the GC only less than 2% of the heap is recovered. This means that the small amount of heap the GC is able to clean will likely be quickly filled again, forcing the GC to restart the cleaning process again. This forms a vicious cycle where the CPU is 100% busy with GC and no actual work can be done and end users of the application face extreme slowdowns

Solution: 


You can resolve this issue by using below options.

Step 1
Disable the error check using -XX:-UseGCOverheadLimit. You can disable the error check by adding the option  -XX:-UseGCOverheadLimit to the Generic JVM arguments. This will help you to stopping these error alerts. Please keep in mind that this error is very likely to be a symptom of a JVM Heap / tuning problem so my recommendation to you is always to focus on the root cause as opposed to the symptom instated disabling the error alert .

Step 2
You may also try to change Garbage Collector Policy. You can add the below policy of Garbage collector option to the Generic JVM arguments.
-XX:+UseConcMarkSweepGC 
-XX:+UseConcMarkSweepGC this can help you in the space issue as it compact all fragment free space after GC run and make you available more contiguous space.
-XX:+UseParallelGC
This -XX:+UseParallelGC parameter help you to run the GC continuously instated of reaching to the memory space threshold.

Step 3
If the option two not works you can  Increase heap size using -Xmx switch in Generic JVM arguments

Step 4
If option three not works add -XX:+HeapDumpOnOutOfMemoryError to Generic JVM arguments which will automatically generate heap dump in case of out of memory issue. Then analyze the dump with IBM Memory Analyzer looking for memory leaks. On the basis of analysis you can work with the development team, optimize your code to use less memory and/or reuse objects instead of creating new ones thus reducing the number of times the garbage collector runs.

Sometime dealing with the OutOfMemoryError is a log process, you need to analyze lot of things for perfect tuning and sometime it just resolved by JVM parameter setting.

Hope this will help you. Kindly comment for your suggestion and quires.  

"Effort only fully releases its reward after a person refuses to quit.”

 Regards,
 Akhilesh B. Humbe

No comments:

Post a Comment

Popular Posts