Sunday, 7 December 2014

Structure of heap in JVM Java

Most of modern GCs are generational. That means java heap memory is separated into few spaces. Spaces are usually distinguished by “age” of objects. Objects are allocated in young space, then, if they survive long enough, eventually promoted to old (tenured) space. That approach rely on hypothesis that most object “die young”, i.e. majority of objects are becoming garbage shortly after being allocated. All HotSpot garbage collectors are separating memory into 5 spaces (though for G1 collector spaces may not be continuous). 

Eden -----> Survivor1 ----------Survivor2 ---------->Tenured------------>parmanent

 Eden are space there objects are allocated,
 Survivor spaces are used to receive object during young (or minor GC),
Tenured space is for long lived objects,
Permanent space is for JVM own objects (like classes and JITed code), it is behaves very like tenured space so we will ignore it for rest of article.

 Eden and 2 survivor spaces together are called young space.

No comments:

Post a Comment