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.

4

1 回答 1

5

“超出 GC 开销限制”意味着您的堆没有用尽,但用于垃圾收集的 CPU 时间量已超过预定义的限制。基本上,您的 JVM 除了收集垃圾之外几乎没有做任何其他事情。这可能是由多种原因造成的,最典型的是堆几乎耗尽,但每个主要 GC 都设法挤出刚好足以满足分配请求。

在您的情况下,可能还有其他原因,例如巨大的堆大小以及过多的主要 GC。您将需要使用诊断工具调查您的情况。我强烈推荐visualgc

于 2013-06-20T08:32:08.357 回答