简体   繁体   中英

rate beetween gc heap allocation and my java program

My application throws java.lang.OutOfMemoryError: GC overhead limit exceeded error. I searched it and get enough information. Oracle says :

Cause: The detail message "GC overhead limit exceeded" indicates that the garbage collector is running all the time and Java program is making very slow progress. After a garbage collection, if the Java process is spending more than approximately 98% of its time doing garbage collection and if it is recovering less than 2% of the heap and has been doing so far the last 5 (compile time constant) consecutive garbage collections, then a java.lang.OutOfMemoryError is thrown. This exception is typically thrown because the amount of live data barely fits into the Java heap having little free space for new allocations. Action: Increase the heap size. The java.lang.OutOfMemoryError exception for GC Overhead limit exceeded can be turned off with the command line flag -XX:-UseGCOverheadLimit.

My question is; how can I track heap allocated by GC , and by my java program. I tried jstat -gcutil but it is not have enough information. Is there a tool that I can see the rate between my java program heap allocation over GC heap allocation? Thanks in advice.

Note that it is not "java heap" vs "gc heap allocation", but CPU time dedicated to the actual program vs CPU time dedicated to GC. The exception is thrown when most of the time is spent in the garbage collector.

This happens when the allocated heap is near to its maximum size (option -Xmx ) and most of the object in the heap are reachable . It is your job to find whether the maximum size is too small (likely if you are using the default values), or there is a memory leak (an object that is preventing a large tree to be collected).

When dealing with this issues, I prefer using jvisualvm, which is provided with the Oracle JDK and gives realtime graphical information.

Latest JVM give more detailed information than earlier ones, but they also use different GC algorithms, which may change the observed results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM