PermGen Out of Memory reasons

Raman picture Raman · Apr 12, 2011 · Viewed 16.7k times · Source

I constantly detect OOM in PermGen for my environment:

  1. java 6
  2. jboss-4.2.3
  3. Not a big web-application

I know about String.intern() problem - but I don't have enough valuable usage of it. Increasing of MaxPermGen size didn't take a force (from 128 Mb to 256 Mb).

What other reasons could invoke OOM for PermGen? What scenario of investigation is the best in such situation (strategy, tools and etc.)?

Thanks for any help

Answer

Dead Programmer picture Dead Programmer · Apr 12, 2011

See this note

  • Put JDBC driver in common/lib (as tomcat documentation says) and not in WEB-INF/lib
  • Don't put commons-logging into WEB-INF/lib since tomcat already bootstraps it

new class objects get placed into the PermGen and thus occupy an ever increasing amount of space. Regardless of how large you make the PermGen space, it will inevitably top out after enough deployments. What you need to do is take measures to flush the PermGen so that you can stabilize its size. There are two JVM flags which handle this cleaning:

-XX:+CMSPermGenSweepingEnabled

This setting includes the PermGen in a garbage collection run. By default, the PermGen space is never included in garbage collection (and thus grows without bounds).

-XX:+CMSClassUnloadingEnabled

This setting tells the PermGen garbage collection sweep to take action on class objects. By default, class objects get an exemption, even when the PermGen space is being visited during a garabage collection.