You see one of the following in jenkins.log:
java.lang.OutOfMemoryError java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: Java heap space
- CloudBees Jenkins Enterprise
- CloudBees Jenkins Operations Center
First step would be to increase the memory available for the JVM. To increase the heap size, you can add or update
-Xmx parameters in the command-line argument of the JVM. For example, to increase memory available to Jenkins to 2Gb (assuming your server has enough memory for that), you would add:
If you continue to encounter issues even after the heap space increase, then we would need more diagnostic information to debug further. In order to investigate the cause of the Out of Memory Exception you will need to enable the following JVM parameters in your Jenkins Environment:
Jenkins using Oracle Java 6 and later:
-verbose:gc -Xloggc:<some-log-file> -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+HeapDumpOnOutOfMemoryError
These JVM parameters can be added to
JAVA_OPTS if Jenkins is running as a standalone application. If Jenkins is running in an application server, please add the JVM parameters as required by the application server.
Note that Jenkins will require a restart for the JVM parameters to be picked up by the JVM.
After the next occurrence of the Out of Memory Exception please upload a Support Bundle and the verbose gc log file to your ticket for review. CloudBees Support will confirm where to upload the heap dump file.
-XX:+PrintHeapAtGC parameter will generate a large amount of logging to the specified gc log file. Please ensure there is adequate file system space when enabling this option. All the information produced by this option is known to the JVM; therefore, there is no extra processing required as a result of enabling this parameter. However, there will be a slight amount of additional I/O overhead which should amount to less than 3%.
-XX:+HeapDumpOnOutOfMemoryError parameter tells the JVM to automatically generate a heap dump file when a heap memory allocation can’t be satisfied. By default, the heap dump file is created in the working directory of the VM, in a file called
java_pidpid.hprof. You can specify an alternative location with parameter
If the above steps do not help with diagnosing the out of memory exception, then we would most likely need a
heap dump to obtain this information. If the above arguments are in place, then the next time an out of memory exception happens it will provide this automatically.