Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would I see only "dead" classloaders from jmap -permstat (except the bootstrap)?

We've been pushing the permgen memory space in our app higher and higher and I'm trying to find out if we have a leak of some sort eating into the permgen area. We don't do hot undeploy/redeploy actions, but we have plenty of proxies, both dynamic and CGLIB-generated. We also do some complicated classloader bits to support various use cases, and I'm suspecting that these might also be a possible contributor to permgen wastage.

So I run jmap -permstat on our running app, hoping to get some insight into what might be filling up our permgen space. (I also run a normal heap dump with both live and dead objects so I can trace down clues that might come from the permstat output).

However, out of the 2400 classloaders listed by jmap permstat, ALL but the bootstrap classloader are listed as "dead". This doesn't make sense, since the app is definitely live, and working.

My understanding was that jmap would report a classloader as "dead" if it were eligible for garbage collection but I must be wrong here...

What am I missing? What does "dead" mean here? Googling around doesn't provide a lot of answers other than the possible misunderstanding that I have here.

like image 458
Scott Avatar asked Nov 14 '22 20:11

Scott


1 Answers

Here are a few ideas:

  1. Upgrade to the latest VM.
  2. If for some reason you're running with -XX:+UseConcMarkSweepGC, then make sure you're also using -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
  3. Do a "Reference Chains from Rootset" in jhat in order to see who’s holding the instance. Remember to exclude weak refs!
  4. This long post is a little complicated, and I haven't tried it myself, but maybe it'll help you.
  5. Try another VM, e.g. JRockit
like image 157
jtoberon Avatar answered Dec 18 '22 06:12

jtoberon