java.lang.OutOfMemoryError: GC overhead limit exceeded causes and solutions

java.lang.OutOfMemoryError: GC overhead limit exceeded causes and solutions

Problem recurring: This error occurred during production and push data from 11 to 23, and there was no other operation.

Explain the STW:

When the jvm is executing the garbage collection thread, other threads will be forced to stop. Only when the garbage collection thread finishes executing, other threads will resume. There will be very little waiting time during this period. This process is stw.

Error meaning:

This error means that the cpu is processing the garbage collection (STW) of the jvm for 98% (the default value), and the memory recovered in the heap is still less than 2%, then the system will report GC overhead limit exceeded.

Error analysis:

Two situations lead to this situation.
One: The server memory is too small to support the operation of jvm.
Two: The memory set for the heap is too small (-Xmx ,-Xms)

find out the problem:

A server is produced and 8 java microservice applications are deployed, which means that 8 jvms are running. Although they do not disturb each other, the memory will be too high in normal times, and it is easy to be OOM, -Xms512m -Xmx512m -Xss1024k -XX:ParallelGCThreads=2 -Djava.compiler=NONE, this is the jvm configuration parameter, explain the meaning of each parameter, -Xmx512m: the maximum memory used by the heap is 512M, -Xms512m: the minimum memory used by the heap is 512M,- Xss1024k: The stack space of a single thread is 1M (the virtual machine stack is shared with the local method stack), -XX:ParallelGCThreads=2: The maximum number of garbage collection threads is 2, that is, two parallel threads are used for garbage collection, -Djava.compiler= NONE: This is the command to disable the JIT (just-in-time compiler) compiler, which is enabled by default (disable JIT, the translator will be used, the translator is more suitable for debugging, and the JIT running program will be faster).

solution:

① Let the error disappear: -XX:-UseGCOverheadLimit, adding this parameter to jvm will make the GC overhead limit exceeded error disappear, and only Java heap space will appear. This is not a fundamental solution, but the error is not reported. Because GC overhead limit exceeded is equivalent to his warning of Java heap space.
②Optimize the configuration of heap parameters: increase the size of the two parameters -Xmx and -Xms.
③Increase server memory: This situation can be used if it is not for memory leaks. Memory leaks only increase memory, but treat the symptoms rather than the root cause.

Guess you like

Origin blog.csdn.net/m0_46897923/article/details/110038556