views:

769

answers:

3

Hi,

My app shows rising 'Old Generation'/'Tenured Generation' size, and when this reaches the max limit for 'Old Gen', then suddenly PermGen size increases. Here are my generation sizings:

-Xmx1200m -Xms1200m -Xmn450m -XX:MaxPermSize=600m -XX:+UseParallelGC

This is on 32 bit Fedora so can't have a bigger heap than this.

The app is not doing any fancy classloading, though it is using Spring IOC and Hibernate, the Spring App-context.xml defines some 1000 Beans.

This app starts with 175MB PermGen, which steadily increases to ~250MB in few hrs, stays that way till Tenured Generation reached ~780 MB, then permgen jumps to ~500MB while Old Gen drops to ~500MB.

This forces me to restart the App on daily basis, and gives me real scare of looming OutOfMemory Error.. Any insights would be very helpful.

Thanks Gala101

13/May: Could someone please throw light on what happens when 'Old Gen' is garbage collected?
Does the jvm put collections from 'Old Gen' into PermGen?
My PermGen spike comes only when collection happens from 'Old Gen', also decrease in OldGen size closely matches increase in PermGen size.
PS: I don't do any live deploy/undeploy as that's sure to eat up PermGen.
Below is a current spanshot from my monitoring page: (the committed part had just jumped from ~250 MB to 500 MB)

    PS Perm Gen
Type    Non-heap memory
Usage   init = 16777216(16384K) used = 254453736(248489K) committed = 504954880(493120K) max = 629145600(614400K)
Peak Usage  init = 16777216(16384K) used = 254453736(248489K) committed = 504954880(493120K) max = 629145600(614400K)
Collection Usage    init = 16777216(16384K) used = 252421536(246505K) committed = 504954880(493120K) max = 629145600(614400K)
A: 

Use jmap to do a memory dump before you restart your server and analyze with Eclipse MAT

leonm
+1  A: 

I would follow leonm's advice to analyze what takes so much memory. I bet you have some kind of nasty memory leak.

You say you don't do any fancy classloading, but Hibernate generates some classes on the fly for you. Do you use some AOP features (e.g. from Spring AOP module?).

Basically, if you are running out of PermGen space, then it seems like your application keeps on producing new classes (because it's classes which are stored in PermGen).

Grzegorz Oledzki
I would try jmap tonight and update..We are not using Spring AOP, but are using lot's of spring beans (which are supposed to be singletons, not sure if these are a contributing factor)..Also, Could you or someone throw light on what happens when 'Old Gen' is garbage collected? Does the jvm put collections from 'Old Gen' into PermGen?My PermGen spike comes only when collection happens from 'Old Gen', also decrease in OldGen size closely matches increase in PermGen size..
Gala101
A: 

Permgen gets leaked if you keep deploying/undeploying apps on the appserver.

Check this link for some more explaination how this is not the appserver's fault.

http://blogs.sun.com/fkieviet/entry/classloader_leaks_the_dreaded_java

Ram
@Ram: I never redploy on a running Tomcat, sorry to have not mentioned that earlier
Gala101
PermGen mostly has class definitions. I wonder what kind of application you have?
Ram