The error "java.lang.OutOfMemoryError: GC overhead limit exceeded" is fairly common. Let'see how to solve it. The "java.lang.OutOfMemoryError: GC overhead limit exceeded is thrown by the throughput old collector (serial or parallel) if more than 98% of the total time is spent doing garbage collection and less than 2% of the heap is recovered.
This is meant to prevent applications from running for an extended period of time while making little or no progress reclaiming objects. It happens for example when the heap is too small, or there is a memory leak, or the old generation is disproportionately small compared to the new generation. This feature can be disabled with the following option:
Disabling this throttle however, will just postpone the memory issue that will turn soon into a "java.lang.OutOfMemoryError: Java heap space."
1) If the new generation size is explicitly defined with JVM options (e.g. -XX:NewSize, -XX:MaxNewSize), decrease the size or remove the relevant JVM options entirely to unconstrain the JVM and provide more space in the old generation for long lived objects.
2) Check for Memory leaks with a memory profiling tool like Eclipse MAT ( https://www.eclipse.org/mat/), Visual VM etc and fix any memory leaks.
3) If you cannot find any memory leak, increase the heap size if current heap is not enough. for example:
4) Enable the standard garbage collection logging options and analyze the logging. For example:
java -verbose:gc -Xloggc:gc.log.`date +%Y%m%d%H%M%S` -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationStoppedTime
5) Check out as well promotion failures and frequent full GC sweeps that fail to free up a lot of memory:
java -XX:+PrintGCDetails -XX:+PrintPromotionFailure -XX:PrintFLSStatistics=1
6) Upgrade JDK version to latest version and use G1GC algorithm. . The throughput goal for the G1 GC is 90 percent application time and 10 percent garbage collection time