MaxTenuringThreshold - 它的工作原理是什么? [英] MaxTenuringThreshold - how exactly it works?

查看:129
本文介绍了MaxTenuringThreshold - 它的工作原理是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索Google。但对我而言仍然不清楚,所以这个问题听起来有点妄想。



呃..我们知道主要内存领域很少。年轻的,终身的(Old gen)和PermGen。

年轻领域分为伊甸园和幸存者(其中两个)。
OldGen用于存活对象。

关于MaxTenuringThreshold - 它使对象不会最终复制到OldGen空间。

这非常清楚和易于理解。



但是,MaxTenuringThreshold... - 它是如何工作的?

垃圾收集器如何处理这些仍然存在直到MaxTenuringThreshold和在有什么办法 ?它们的位置在哪里?
对象被复制回到Survivor空间以进行垃圾回收..或者它发生在其他方面?



没有找到任何好的解释,所以我会非常感谢任何有用的链接或解释。

解决方案

Java堆中的每个对象都有一个头通过垃圾收集(GC)算法。年轻的空间收集器(负责对象提升)使用这个头部的几个数据来跟踪已经存活的收集对象的数量(32位JVM使用4位,64位可能更多) 。



在年轻的空间收集过程中,每个对象都被复制。对象可以被复制到其中一个生存空间(在年轻GC之前是空的空间)或旧空间。对于每个被复制的对象,GC算法会增加它的年龄(收集数量存活),并且如果年龄高于当前持续时间阈值,它将被复制(提升)到旧空间。如果生存空间变满(溢出),Object也可以直接复制到旧空间。



Object的旅程具有以下模式:




  • 分配给伊甸园

  • 从伊甸园复制到年轻GC的生存空间
    <由于年轻的GC(这可能会发生几次),从生存到(其他)的生存空间被复制到生存空间(这可能会发生很多次)
  • 由于年轻GC(或可能的伊甸园)完整的GC)



实际的持续时间阈值由JVM动态调整,但MaxTenuringThreshold设置上限它。



如果您设置MaxTenuringThreshold = 0,所有对象将立即被提升。

我有

I've been Googling all day about that. But it's still not clear for me, so the question may sound a bit delusional.

Well.. we know that there's few main memory domains. Young, Tenured (Old gen) and PermGen.

Young domain is divided into Eden and Survivor (which two). OldGen is for surviving objects.
Regarding MaxTenuringThreshold - it keeps objects from being finally copied to the OldGen space too early.
It's pretty clear and understandable.

But that "MaxTenuringThreshold"... - how it is exactly works?
How garbage collector is dealing with these objects which are still surviving till MaxTenuringThreshold and in what way ? Where's they located ?
Objects are being copied back to Survivor spaces for garbage collection.. or it happens somehow else?

Haven't found any good explanation of this, so i'll be much appreciate any useful links or explanations.

解决方案

Each object in Java heap has a header which is used by Garbage Collection (GC) algorithm. The young space collector (which is responsible for object promotion) uses a few bit(s) from this header to track the number of collections object that have survived (32-bit JVM use 4 bits for this, 64-bit probably some more).

During young space collection, every single object is copied. The Object may be copied to one of survival spaces (one which is empty before young GC) or to the old space. For each object being copied, GC algorithm increases it's age (number of collection survived) and if the age is above the current tenuring threshold it would be copied (promoted) to old space. The Object could also be copied to the old space directly if the survival space gets full (overflow).

The journey of Object has the following pattern:

  • allocated in eden
  • copied from eden to survival space due to young GC
  • copied from survival to (other) survival space due to young GC (this could happen few times)
  • promoted from survival (or possible eden) to old space due to young GC (or full GC)

the actual tenuring threshold is dynamically adjusted by JVM, but MaxTenuringThreshold sets an upper limit on it.

If you set MaxTenuringThreshold=0, all objects will be promoted immediately.

I have few articles about java garbage collection, there you can find more details.

这篇关于MaxTenuringThreshold - 它的工作原理是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆