0

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.

Masoud
  • 8,020
  • 12
  • 62
  • 123
mft
  • 319
  • 1
  • 5
  • 19

1 Answers1

2

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.

Community
  • 1
  • 1
Javier
  • 12,100
  • 5
  • 46
  • 57
  • should i use result set for my db operations? i have 7 million record to select and insert.i have already use 8 threads. – mft Feb 24 '15 at 12:08
  • and when i track with visualvm, heap size allocation starts with about 486 mb max. my program still working and heap size is now about 516 mb. it would not be increase i thing. it is shrinking. any comment about that? it would be helpful – mft Feb 24 '15 at 12:14