Friday 16 September 2011

first time i am dealing with heap and garbage collector .



  • HEAP and GARBAGE COLLECTOR

JVM term in field of JAVA . when sun introduces its JVM . before sun's jvm , IBM vm is working as sun in the market . but when SUN came up with a JVM after it only sun's sun shine in the sky , and IBM VM hide in some cloud .

this theory is typical but read this , how sun is different than any other . we all know that in java every thing is JVM , and inside JVM there is a heap . but do you know that we have two parts inside this heap .
1. permanent heap .
2. old or young region .

now question in your mind where object will reside , now listen our object will reside in old or young region and in permanent region our class code resides . now how these two are seperated . these two are seperated by layer ( means physically )


  • JVM uses two parameters for representing heap . 

XX : MaxPermSize (Permanent region)
Xmx (Maximum Java Heap size)

now do you think that JVM is only built for heap . the another main task of JVM is class loading and class unloading , class unloading is the term which is most famous in the field of java :- now why ?

class unloading is a term which i want to explain , because i like this part . what is unloading and how unloading is performed . class unloading is done when all objects are set as unused , now you something which collects these objects , this term is knows as garbage collector .

:- a problem is there in unloading a class , problem is that when you unload a class at that time memory leak can occur , so this can cause an error , which is known as
                            
                                                 OUT_OF_MEMORY_EXCEPTION .

garbage collector , i said that it like to collect the objects which are unused . so this collection is done under 3 cases . means 3 types of garbage collection is done .
1. default collection .
2. manual collection .
3. low pause mark sweep collector .

default collection :- default collection is simple and provide no extra advantage .

manual collection :- manual collection is a term , where you we can tune this garbage collection .

low pause mark sweep collector :- this is the field which is most important , this is same as default but if you  are in-compatible with default collection than refer to it . now what is the benifit of refering it . This collector is particularly helpful with the very large heaps that are used with the 64-bit JVM, or applications that have a large set of long-lived data, also and that maintains comparatively good cache utilization .

No comments: