3

I was profiling a java functional test that was taking a long time and exhibiting occasional OOM's (in C heap, not java) and I found a really sub-optimal behavior in the java serial GC (and it probably applies to all java GC's.)

Here's a sample of Permgen statistics at full GC points from the test run (size in KB):

before  after   commit
167935  167935  167936
172031  172031  172032

As you can see, permgen space isn't getting cleaned by these full gc runs. Not a big deal, but it points to these full gc's being useless. Additionally, the commit value is a little funny. I assumed the commit value for a gc log entry would be the value after the commit size was increased. I now think it is actually the commit value prior to the full GC run.

Additionally, I think that the permgen commit size grows at a fixed, un-tunable size of 4MB (172032K - 167936K) per full GC run. This means that if you start with a default permgen size of, say 64mb, and when your application is fully up it requires 128mb of permgen, it would require 16 full gc's for permgen to reach its final commit size.

In the case of the functional test I was profiling, 58 full gc's had to run, each taking 0.5 to 2 seconds. By making the jvm argument -XX:PermSize equal to -XX:MaxPermSize I was able to reduce that to zero full GC's (without significantly increasing the much-much-faster new-generation gc's) and reduce the GC time reported by the gc instrumentation messages by 90%, from 90 seconds to 9 seconds.

I looked numerous places but I couldn't find a different tuning parameter for the commit size growth rate for the permgen heap. It's kind of ugly to fully allocate the maximum possible size of the permgen heap at program startup. Does anyone know of an alternative to increasing PermSize to equal MaxPermSize that will achive similar results without allocating so much memory at startup? Why is the permgen commit increment so small and fixed?

4

1 回答 1

0

Permgen 不会被垃圾收集。(在正常情况下)。Permgen 是保存 Java 运行时的实际类对象和其他“胆量”的地方。当您的应用程序初始化和使用各种类和/或加载和/或使用 jar 时,这些关联的类文件本质上存储在 permgen 中。

必须有其他与您的应用程序特别相关的相关参数来解释您的观察。

permgen 增加和垃圾收集之间确实没有记录的关系。Permgen 用于存储jvm 使用的静态数据,通常不会被收集(除了在极少数情况下,即 ClassLoader 加载类然后说 ClassLoader 超出范围)

于 2012-08-14T21:06:03.560 回答