1

In our Tomcat application, we get an "OutOfMemoryError: GC overhead limit exceeded". But Runtime.getRuntime().freeMemory() reports 576 MB are free.

How can this happen?

The error is thrown from within the SQL Server JDBC driver, and I cannot imagine this would try to allocate hundreds of megabytes in one memory request. And the GarbageCollectorMXBeans counts for "PS Scavenge" as well as "PS MarkSweep" did not increase much in the minutes before the error was thrown.

Runtime.getRuntime().maxMemory() as well as Runtime.getRuntime().totalMemory() report 4.5 GB. This is running with the 64 bit Sun JVM for Java 7.

fge
  • 119,121
  • 33
  • 254
  • 329
FrankPl
  • 13,205
  • 2
  • 14
  • 40
  • Please paste the entire stack trace - did it go out of memory due to heap exhaustion or perm gen. or something else... – Scorpion Jun 20 '13 at 08:30
  • 2
    This answer may be helpful: http://stackoverflow.com/a/1393503 - it explains the meaning of this particular OutOfMemoryError – konradstrack Jun 20 '13 at 08:31
  • Does your application do `System.gc()` by any chance? – fge Jun 20 '13 at 08:35

1 Answers1

6

"GC overhead limit exceeded" means that your heap is not exhausted, but that the amount of CPU time spent on garbage collection has exceeded a predefined limit. Basically, your JVM is doing little else besides collecting garbage. This may be caused by a variety of reasons, the most typical being that the heap is nearly exhausted, but every major GC manages to squeeeze out just enough to satisfy the allocation request.

In your case there may be other causes, such as an enormous heap size along with too many major GC's. You will need to investigate your situation with a diagnostic tool. I highly recommend visualgc.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436