Saturday 1 October 2022

What is PermGen?

PermGen is memory area which was part of heap prior to Java 8. This is used to load class and method objects which means it was directly related to the number of classes objects being created. So when number of classes increases there objects can also increase and hence we use to face one issue java.lang.OutOfMemory error due to PermGen Size. We use to increase PermGen size using xx:MaxPermGen .


But there is new change in java 8 wherein this PermGen has been replaced by Metaspace which means there is no PermGen in java 8 onwards.

 Old JVM memory consist of  1)Heap  2)Native memory  

             wherein Heap consists of  

              a)Old generation.     b)New Generation.    c)PermGen

 New JVM memory consists of  1)Heap  2)Native memory

           wherein Heap consists of  

              a)Old generation.     b)New Generation

             Native memory consists of 

             a)Metaspace

Now metaspace is controlled by the native memory which is dependent of the host .So in case many classes are loaded due to xyz reason it may happen that process size can increase immensely and by so entire server can crash not only application.

So for this we have new parameter using which we can we can limit size of metaspace  given by xx::MaxMetaspaceSize. 


Conclusion:: 

1)we need to monitor heap as well as process size now. Process size can be monitored using system utilities like top in unix/linux and Task Manager in windows.

2)Jmap can be used as follows: Jmap -permstat <PID> 

3)No more PermGen space from java 8 onwards. Inclusion of metaspace.

3)QA should be made aware of this while doing testing.




No comments:

Post a Comment