edgarmtze
edgarmtze

Reputation: 25058

PERM Area of Java

Does garbage collection occurs in PERM Area of Java Heap ?

PERM area is used to store meta data about classes, methods, variable etc... also String Pool created in PERM area of heap so I believe garbage collection does not occur here?

Upvotes: 4

Views: 677

Answers (2)

Dead Programmer
Dead Programmer

Reputation: 12585

With each deployment, 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.

Upvotes: 3

MeBigFatGuy
MeBigFatGuy

Reputation: 28598

I believe that theoretically if a class loader is garbage collected the classes that were loaded by that classloader can be garbage collected. These classes would be in the Permanent generation.

Upvotes: 0

Related Questions