I need to disable the GC Overhead limit in my CentOS
server. The reason for this is to temporarily prevent java.lang.OutOfMemoryError: GC overhead limit exceeded
exceptions.
But i'm a zero at Linux + Java systems and don't have any clue on how to run this command line: -XX:-UseGCOverheadLimit
You'll need to pass it to the JVM as an argument. You say your hosting a webapp in Apache Tomcat. You can set the environment variable CATALINA_OPTS
to equal -XX:-UseGCOverheadLimit
. You'll have to do this in the script that actually starts tomcat if your running it as a service, and in fact the Tomcat script for CentOS probably has a CATALINA_OPTS
variable in it that you can add to or set.
That being said, eliminating the ability for the garbage collector to throw an OutOfMemoryError (OOME) due to overhead may not fix the problem. OOME due to overhead basically means the program was not making any useful progress due to the GC operations taking a lot of time. This can happen when free memory is very low and lots of full GC passes have to be made frequently. If you disable the error, its possible the program will simply become unresponsive before finally actually running out of memory in the heap at some undefined point in the future which will still cause an OOME to be thrown for heap space instead of overhead.
A better solution would be instead to increase the amount of memory Tomcat is allowed to use by setting using the -Xmx argument (again passed in via CATALINA_OPTS
). -Xmx2g
would set max heap to 2 GiB for instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With