1.jvm年轻代内存回收 Eden:survivor=8:1
2.采用复制算法 Eden区满后标记后将存活对象房子survivor0里 如下图:
下一次Eden 满了 会将对象放到之前清空的 survivor1的区域里
问:
1.survivor的对象如何被清理 同样是标记-清除/整理算法嘛?
2.对象从年轻代到老年代是经过每次gc时候 还是动态的进入,当达到某一条件晋升?什么条件
PHP中文网2017-04-18 10:53:28
Hello lz, I saw your comment on my article A Brief Analysis of JVM Memory Management before, and I also saw your question. It’s mentioned in my articles:
The survivor area belongs to the young generation and uses the copy collection algorithm
Objects that are still alive after being moved between the two Survivor areas several times (default is 15 times) will finally be moved to the old generation
Exceptionally large objects enter the old age directly
怪我咯2017-04-18 10:53:28
Recommended to read "In-depth Understanding of Java Virtual Machine".
1. The GC algorithms of the new generation are almost all replication algorithms, that is to say, the survivor is also copied to the old generation.
2. There are several situations when objects move from the new generation to the old generation
2.1有一个年龄参数MaxTenuringThreshold用来判断,每次对象熬过一次GC,年龄加1,当到达设定的阈值时,可以进入老年代。
2.2比较大的对象(需要大量连续的内存空间),同样,虚拟机也提供了一个参数PretenureSizeThreshold,可以设置这个值,当对象大于设置值可以直接进入老年代。
2.3如果Survivor空间中相同年龄的对象大小总和大于Survivor空间的一般,则年龄大于或等于该年龄的对象就可以进入老年代。这里是属于动态判定,适应那些内存较小的情况
There are some other situations, you can read the book