Java 堆术语:年轻代、年老代和永久代? [英] Java heap terminology: young, old and permanent generations?

查看:31
本文介绍了Java 堆术语:年轻代、年老代和永久代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试理解 Java 堆术语中 youngoldpermanent 的概念是什么,更具体地说三代人之间的互动.

I'm trying to understand What the concepts of young, old and permanent generations are in the Java heap terminology, and more specifically the interactions between the three generations.

我的问题是:

  • 什么是年轻代?
  • 什么是老年代?
  • 什么是永久代?
  • 这三代人如何相互作用/相互关联?

推荐答案

这似乎是一个常见的误解.在 Oracle 的 JVM 中,永久代不是堆的一部分.它是用于类定义和相关数据的单独空间.在 Java 6 及更早版本中,实习字符串也存储在永久代中.在 Java 7 中,interned 字符串存储在主对象堆中.

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.

我喜欢 Oracle 的 中对每个空间的描述JConsole 指南:

I like the descriptions given for each space in Oracle's guide on JConsole:

对于 HotSpot Java VM,内存串行垃圾收集池以下是.

For the HotSpot Java VM, the memory pools for serial garbage collection are the following.

  • Eden Space(堆):最初分配内存的池对于大多数对象.
  • Survivor Space(堆):包含幸存对象的池伊甸园的垃圾收集空间.
  • Tenured Generation(堆):包含已存在对象的池在幸存者空间待了一段时间.
  • Permanent Generation(非堆):包含所有反射的池虚拟机本身的数据,例如类和方法对象.和使用类数据共享的 Java VM,这一代分为只读和读写区域.
  • 代码缓存(非堆):HotSpot Java VM 还包括代码缓存,包含用于的内存native的编译和存储代码.

Java 使用分代垃圾收集.这意味着如果你有一个对象 foo(它是某个类的一个实例),它存活的垃圾收集事件越多(如果仍然有对它的引用),它得到的提升就越大.它从年轻代开始(它本身被划分为多个空间 - Eden 和 Survivor),如果存活时间足够长,最终会进入年老代.

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 堆术语:年轻代、年老代和永久代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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