JVM memory deal with the heap memory which is further divided into two different generations. The two different generations ,
1. Young Generation
2. Tenured Generation
are implemented in the heap area. These generations are used for keeping track of object's state. Newly object got place in the young generation. As it grows old and at the time of garbage collection, those who are not garbage collected are shifted to the tenure generation, which is more likely to live long are compared to which who got garbage collected at the young generation. Like this when garbage collection takes place the state of the object changes from young to tenure generation.
There is one more generation present in the JVM which is not a part of heap memory are termed as Permanent generation. It is used to stored the java classes and method object meta data information's.It also keep track of JVM generated object's for predefined classes. It has a fixed size of memory at the start of JVM, to change its size we need to do it explicitly by writing some commands. And its minimum and maximum size differs with every JDK.
At very initial stage of java, there was not concept of permanent generation as both java objects and java classes are stored in the same memory area. Permanent generation comes into existence to enhance the performance as because at the earlier days , after a lot of analysis by the java vendor, they come to know that mostly all the java classes are static, that means no objects are created for that class. To maintain the simplicity and to enhance the performance a Permanent generation is introduced with the fixed memory ( not a part of heap ) to store the java classes meta data information . As we increases dealing with the objects, we need to keep track of its related class information as well which is in a separate memory i.e Permanent generation. It would be different to trace the object and its related class because class changes it state in regular basis. While garbage collecting the object from the tenure generate we need to know about it through its class information which is maintained in the permanent generation as a object. Rather it is possible by parallel collector to trace the old and new memory location of the java classes, but it makes a performance issue and slows down the performance of the JVM. So finally , they feel it would be better to remove the existence of permanent generation but replaces by MetaSpace.
Note: Now there will not be an issue of java.lang.OutOfMemoryError: PremGem .
0 comments:
Post a Comment