年轻,终身和烫发一代 [英] Young , Tenured and Perm generation

查看:117
本文介绍了年轻,终身和烫发一代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对堆,年轻,终身和烫发一代感到困惑。



任何人都可以解释吗?

解决方案

简称为世代垃圾收集器。应用程序中的对象根据创建的位置以及使用方式而存在不同的时间长度。这里的关键洞察是,针对短期和长期使用的对象使用不同的垃圾收集策略可以使GC针对每种情况进行专门优化。 $ b 松散地说,作为对象生存的年轻一代重复的垃圾收集,他们被迁移到永久代 是一个特殊情况,它包含JVM需要的对象,它们不一定代表程序中的对象,例如表示类和方法的对象。



由于年轻一代通常会包含大量垃圾,因此它会针对一次性删除大量未使用的对象进行优化。 由于它包含了更长时间的对象,因此对于快速垃圾回收进行了优化,而不会浪费大量内存。



随着垃圾收集技术细节已经变得非常复杂并且取决于您的JVM以及它的配置方式。您应该阅读您正在使用的特定JVM的文档如果你需要确切地知道发生了什么。



也就是说,有一个简单的历史安排,这在概念层面仍然有用。从历史上看,年轻一代可以是 copy收藏家 mark and sweep collector 。一个拷贝收集器本质上没有CPU成本来摆脱垃圾,大部分的成本是维护活动对象,这个效率的代价是内存使用率更高。标记和清除收集器为实时和未使用的对象支付一些CPU成本,但更有效地利用内存。


I'm confused with Heap,Young,Tenured and Perm generation.

Could anyone please explain?

解决方案

The Java garbage collector is referred to as a Generational Garbage Collector. Objects in an application live for varying lengths of time depending on where they are created and how they are used. The key insight here is that using different garbage collection strategies for short lived and long lived objects allows the GC to be optimised specifically for each case.

Loosely speaking, as objects "survive" repeated garbage collections in the Young Generation they are migrated to the Tenured Generation. The Permanent Generation is a special case, it contains objects, that are needed by the JVM, that are not necessarily represented in your program, for example objects that represent classes and methods.

Since the Young Generation will usually contain a lot of garbage in it, it is optimised for getting rid of a lot of unused objects at once. The Tenured Generation since it contains longer lived objects is optimised for speedy garbage collection without wasting a lot of memory.

With improvements in garbage collection technology the details have become pretty complex and vary depending on your JVM and how it has been configured. You should read the documentation for the specific JVM you are using if you need to know exactly what is happening.

That said, there is a simple historical arrangement this is still useful at a conceptual level. Historically the Young Generation would be a copy collector and the Tenured Generation be a mark and sweep collector. A copy collector pays essentially no CPU cost for getting rid of garbage, most of the cost is in maintaining live objects, the price of this efficiency is heavier memory usage. A mark and sweep collector pays some CPU cost for both live and unused objects but utilizes memory more efficiently.

这篇关于年轻,终身和烫发一代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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