在HotSpot中如何实现分代回收

3 篇文章 0 订阅
题目是个大话题,不过在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.
[color=red]HotSpot默认回收器有两代:年轻代和年老代。大多数的分配都在年轻代中完成。年轻代对对象做了优化,即相对于回收间隔来说,这些对象拥有更短的生命周期。在年轻代中的一些对象,加入经过几次回收之后仍然存在,那么它们将被移至年老代中。相对来说,年轻代往往比较小并且会被更频繁的进行垃圾回收,而年老代正好相反。[/color]

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.
[color=red]年轻代回收器是基于复制的。年轻代被分为三个空间:eden-space, to-space, and from-space.分配的动作就在eden-space和from-space中完成。年轻代经过回收以后,我们期望的结果是大部分的对象将会被回收,而那些没有被回收的对象就被复制到to-space中,加入存活下来的对象不能所有都装进to-space,那么剩下的对象直接将被送进年老代。当然,也可以选择在年轻代中并行收集(也就是使用多个线程同时进行垃圾回收的工作)。[/color]

The tenured generation is collected with a mark-sweep-compact collection. There is an option to collect the tenured generation concurrently.
[color=red]年老代使用mark-sweep-compact策略进行回收,也可以选择并发回收。[/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值