/ Java HotSpot VM PermGen space ~ Java EE Support Patterns


Java HotSpot VM PermGen space

I often get a lot of questions from other application support colleagues regarding the permanent generation space. This short post will provide you with both a high level summary and graphical view of this special Java HotSpot VM memory block.
PermGen space

The Java HotSpot VM permanent generation space is the JVM storage used mainly to store your Java Class objects.  The Java Heap is the primary storage that is storing the actual short and long term instances of your PermGen Class objects.

The PermGen space is fairly static by nature unless using third party tool and/or Java Reflection API which relies heavily on dynamic class loading.
It is important to note that this memory storage is applicable only for a Java HotSpot VM; other JVM vendors such as IBM and Oracle JRockit do not have such fixed and configurable PermGen storage and are using other techniques to manage the non Java Heap memory (native memory).

Find below a graphical view of a JVM HotSpot Java Heap vs. PermGen space breakdown along with its associated attributes and capacity tuning arguments.


Evaluating permanent generation space is also important for applications. An experience I would like to share...
We had an application(version 1) running on tomcat server with no issues. We were using conncurrentMarkGC.
In version 2, We added spring and JAXB (stuff that uses reflections and dynamically loads/unloads classes). We started seeing concurrent mode failure during the start up of the application.

(concurrent mode failure): 0K->5239K(3145728K), 0.1788830 secs] 102690K->5239K(4089472K), [CMS Perm : 21247K->21053K(21248K)], 0.1790960 secs] [Times: user=0.15 sys=0.04, real=0.18 secs]

I added the PermSize and MaxPermSize in JVM options and set it to 128M.

It took care of the issue.


Thanks Shan for sharing your experience and problem case,

PermGen space analysis is indeed important. New project implementations often introduce an increase static and / or dynamic code footprint. Reflection calls under heavy load has the side effect to increase the PermGen space requirement which can increase the frequency of Full GC if you don't plan proper PermGen capacity at the beginning.

PermGen space will eventually go away (target: JDK 1.8). This will require Java programmers and support teams to monitor more closely the Java native memory space.


Post a Comment