錯誤:java.lang.OutOfMemoryError: GC overhead limit exceeded
What is causing it?
The?java.lang.OutOfMemoryError: GC overhead limit exceeded?error is the JVM’s way of signalling 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。
也就是說GC試圖回收內(nèi)存,但是什么也沒有回收到触趴。默認(rèn)情況下乎完,JVM花費(fèi)了98%的時間在GC上馏臭,但是GC過之后只有不到2%的堆內(nèi)存被回收舔庶。
What would happen if this GC overhead limit would not exist?
Note that the?java.lang.OutOfMemoryError: GC overhead limit exceeded?error is only thrown when 2% of the memory is freed after several?GC cycles. 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. End users of the application face extreme slowdowns – operations which normally complete in milliseconds take minutes to finish白胀。
So the “java.lang.OutOfMemoryError: GC overhead limit exceeded” message is a pretty nice example of a?fail fast?principle in action废恋。
簡單來講谈秫,就是一次GC過后扒寄,并沒有回收到內(nèi)存,很快又會進(jìn)行GC拟烫,極端情況下會循環(huán)GC(關(guān)鍵是并沒有回收到可用內(nèi)存)该编,從而導(dǎo)致CPU 100%負(fù)載。
PS:參見?https://plumbr.eu/outofmemoryerror/gc-overhead-limit-exceeded