问题描述
我试图理解Java堆术语中 young , old 和永久代的概念,更具体地说,三代之间的相互作用。
我的问题是:
这似乎是一种常见的误解。在Oracle的JVM中,永久代不是堆的一部分。它是类定义和相关数据的独立空间。在Java 6及更早版本中,interned字符串也存储在永久代中。在Java 7中,interned字符串存储在主对象堆中。
这是一个。
我喜欢在Oracle的:Java使用分代垃圾收集。这意味着如果你有一个对象foo(它是某个类的一个实例),它存活的垃圾收集事件就越多(如果仍然有引用的话),它就会被提升。它开始于年轻一代(本身分为多个空间 - 伊甸园和幸存者),如果能够长期存活下来,它们最终会成为终身的一代。
I'm trying to understand how the concepts of young, old and permanent generations in the Java heap terminology, and more specifically the interactions between the three generations.
My questions are:
- What is the young generation?
- What is the old generation?
- What is the permanent generation?
- How does the three generations interact/relate to each other?
This seems like a common misunderstanding. In Oracle's JVM, the permanent generation is not part of the heap. It's a separate space for class definitions and related data. In Java 6 and earlier, interned strings were also stored in the permanent generation. In Java 7, interned strings are stored in the main object heap.
Here is a good post on permanent generation.
I like the descriptions given for each space in Oracle's guide on JConsole:
Java uses generational garbage collection. This means that if you have an object foo (which is an instance of some class), the more garbage collection events it survives (if there are still references to it), the further it gets promoted. It starts in the young generation (which itself is divided into multiple spaces - Eden and Survivor) and would eventually end up in the tenured generation if it survived long enough.
这篇关于Java堆术语:年轻的,老的和永久的世代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!