学习JVM原理-5.Young Generation和Tenured Generation

摘自《深入理解Java虚拟机》周志明著

GC的算法不止一种,不同的对象适用不同的算法。
因此JVM对内存进行了分区,不同区域适用不同算法

一般分作Young Generation和Tenured Generation两个区域

  1.
Young Generation一般用Copying算法,但空闲部分只设10%(因为研究表明GC时大部分对象都会被杀);存活对象转移时,如果空闲部分不够装,则把装不下的放到Tenured Generation中(参见Eden, Survivor等术语)

  2.
Tenured Generation用来装Young Generation中转移过来的对象(在Young Generatioin中经历了足够多次GC,或者Young Generation中已放不下),已及一些不方便放在Young Generation中的对象,如大对象等。
Tenured Generation一般用Mark-Sweep算法或其改良版


    

Young Generation可以再分为
两部分

Young generation memory consists of two parts,
Eden space and
survivor space. Shortlived objects will be available in Eden space. Every object starts its life from Eden space. When GC happens, if an object is still alive then it will be moved to survivor space and other dereferenced objects will be removed.

Young Generation的GC称作Minor GC,当Eden区没有足够空间进行分配时,就会发起一次Minor GC

Tenured Generation的GC称作Major GC/Full GC,它的速度会比Minor GC慢10倍以上

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.