java内存池是如何划分的? [英] How is the java memory pool divided?

查看:25
本文介绍了java内存池是如何划分的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 jconsole 监视 Java 应用程序.内存选项卡可让您选择:

I’m currently monitoring a Java application with jconsole. The memory tab lets you choose between:

Heap Memory Usage
Non-Heap Memory Usage
Memory Pool "Eden Space"
Memory Pool "Survivor Space"
Memory Pool "Tenured Gen"
Memory Pool "Code Cache"
Memory Pool "Perm Gen"

它们之间有什么区别?

推荐答案

堆内存

堆内存是 Java VM 为所有类实例和数组分配内存的运行时数据区域.堆的大小可以是固定的,也可以是可变的.垃圾收集器是一种自动内存管理系统,可以为对象回收堆内存.

Heap memory

The heap memory is the runtime data area from which the Java VM allocates memory for all class instances and arrays. The heap may be of a fixed or variable size. The garbage collector is an automatic memory management system that reclaims heap memory for objects.

  • Eden Space:最初为大多数对象分配内存的池.

  • Eden Space: The pool from which memory is initially allocated for most objects.

Survivor Space:包含在 Eden 空间的垃圾收集中幸存下来的对象的池.

Survivor Space: The pool containing objects that have survived the garbage collection of the Eden space.

Tenured GenerationOld Gen:包含在 Survivor 空间中存在一段时间的对象的池.

Tenured Generation or Old Gen: The pool containing objects that have existed for some time in the survivor space.

非堆内存包括所有线程共享的方法区和Java VM内部处理或优化所需的内存.它存储每个类的结构,例如运行时常量池、字段和方法数据,以及方法和构造函数的代码.方法区在逻辑上是堆的一部分,但根据实现,Java VM 可能不会对其进行垃圾收集或压缩.与堆内存一样,方法区的大小可能是固定的,也可能是可变的.方法区的内存不需要是连续的.

Non-heap memory includes a method area shared among all threads and memory required for the internal processing or optimization for the Java VM. It stores per-class structures such as a runtime constant pool, field and method data, and the code for methods and constructors. The method area is logically part of the heap but, depending on the implementation, a Java VM may not garbage collect or compact it. Like the heap memory, the method area may be of a fixed or variable size. The memory for the method area does not need to be contiguous.

  • 永久代:包含虚拟机本身所有反射数据的池,例如类和方法对象.使用类数据共享的Java VM,这一代分为只读区和读写区.

  • Permanent Generation: The pool containing all the reflective data of the virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas.

代码缓存:HotSpot Java VM 还包括代码缓存,其中包含用于编译和存储本机代码的内存.

Code Cache: The HotSpot Java VM also includes a code cache, containing memory that is used for compilation and storage of native code.

这里有一些关于如何使用 Jconsole 的文档.

这篇关于java内存池是如何划分的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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