JVM学习笔记-压缩收集器(Compacting Collectors)

31 篇文章 0 订阅
5 篇文章 0 订阅

Compacting Collectors

Garbage collectors of Java Virtual Machines will likely have a strategy to combat heap fragmentation. Two strategies commonly used by mark and sweep collectors are compacting and copying. Both of these approaches move objects on the fly to reduce heap fragmentation. Compacting collectors slide live objects over free memory space toward one end of the heap. In the process the other end of the heap becomes one large contiguous free area. All references to the moved objects are updated to refer to the new location.

Java虚拟机的垃圾收集器可能有对付堆内存碎块的策略。标记并清除收集器通常使用的两种策略是压缩和拷贝,这2种方法都是快速的移动对象来减少堆碎块,。压缩收集器把活动的对象越过空闲区滑动到堆得一端,这个过程中,堆的另一端出现一个大的连续空闲区,所有被移动的对象引用也会被更新指向新的位置。

 

Updating references to moved objects is sometimes made simpler by adding a level of indirection to object references. Instead of referring directly to objects on the heap, object references refer to a table of object handles. The object handles refer to the actual objects on the heap. When an object is moved, only the object handle must be updated with the new location. All references to the object in the executing program will still refer to the updated handle, which did not move. While this approach simplifies the job of heap defragmentation, it adds a performance overhead to every object access.

更新被移动的对象的引用通过一个间接对象引用层可以变的更简单。不直接引用堆中的对象,对象的引用时间上是指向一个对象句柄表,对象句柄才指向堆中对象的实际位置。当对象被移动时候,只有这个句柄需要被更新为新位置,这个方法简化了消除堆碎块的工作,但是每一次对象访问都带来了性能的损失。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值