Friday, December 7, 2012

Brief on JVM Heap Memory

let’s take a look at how the JVM organizes memory into different areas. This has been helping several garbage collection algorithms and memory management to work efficiently. These areas are called Generations which are categorized based on the life of the objects.

1.       There are separate pools that hold objects of different age. They are
a.       Young Generation
b.      Old Generation
c.       Permanent Generation

2.       Young Generation:
a.       Most of the objects are initially placed in the young generation space.
b.      Young Generation Garbage collection occurs frequently and operates at high speed since the young generation space contains lots of objects that are less referenced.
c.       In Java HotSpot VM, Young Generation again categorized into
                                                               i.      Eden Space : Most objects are initially allocated in the Eden space
                                                             ii.      Survivor Space: Objects that survive atleast one young garbage collection is moved to survivor space.

3.       Old Generation:
a.       Objects that survived Garbage Collection (From Survivor Space) are tenured or Promoted to the Old Generation
b.      Garbage Collection algorithm that works on this space is designed to be more space efficient since Old generation occupies most of the heap.

4.       Permanent Generation (PermGen) :
a.       Permanent Generation usually contains the objects that describe classes & methods and also classes & methods.

No comments:

Post a Comment