在HotSpot中如何实现分代回收

编程技术  /  houtizong 发布于 3年前   130
    题目是个大话题,不过在Oracle官方的FAQ里,个人觉得短小而精辟。短短几句话,可以让那些对generational collector不太清楚的朋友们迅速了解:

The default collector in HotSpot has two generations: the young generation and the tenured generation. Most allocations are done in the young generation. The young generation is optimized for objects that have a short lifetime relative to the interval between collections. Objects that survive several collections in the young generation are moved to the tenured generation. The young generation is typically smaller and is collected more often. The tenured generation is typically larger and collected less often.
HotSpot默认回收器有两代:年轻代和年老代。大多数的分配都在年轻代中完成。年轻代对对象做了优化,即相对于回收间隔来说,这些对象拥有更短的生命周期。在年轻代中的一些对象,加入经过几次回收之后仍然存在,那么它们将被移至年老代中。相对来说,年轻代往往比较小并且会被更频繁的进行垃圾回收,而年老代正好相反。

The young generation collector is a copying collector. The young generation is divided into 3 spaces: eden-space, to-space, and from-space. Allocations are done from eden-space and from-space. When those are full a young generation is collection is done. The expectation is that most of the objects are garbage and any surviving objects can be copied to to-space. If there are more surviving objects than can fit into to-space, the remaining objects are copied into the tenured generation. There is an option to collect the young generation in parallel.
年轻代回收器是基于复制的。年轻代被分为三个空间:eden-space, to-space, and from-space.分配的动作就在eden-space和from-space中完成。年轻代经过回收以后,我们期望的结果是大部分的对象将会被回收,而那些没有被回收的对象就被复制到to-space中,加入存活下来的对象不能所有都装进to-space,那么剩下的对象直接将被送进年老代。当然,也可以选择在年轻代中并行收集(也就是使用多个线程同时进行垃圾回收的工作)。

The tenured generation is collected with a mark-sweep-compact collection. There is an option to collect the tenured generation concurrently.
年老代使用mark-sweep-compact策略进行回收,也可以选择并发回收。
上一篇:HBase异常记录
下一篇:ssh+Weblogic 12c

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

留言需要登陆哦

技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成

网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];

      订阅博客周刊 去订阅

文章归档

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客