什么是烫发空间?
在学习 Java 内存分析时,除了“堆”之外,我还不断看到术语“永久空间”。 我知道堆是什么 - 什么是 Perm 空间?
While learning about java memory profiling, I keep seeing the term "perm space" in addition to "heap." I know what the heap is - what's perm space?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
它代表永久代:
It stands for permanent generation:
Perm space
用于保存加载类的信息以及一些其他高级功能,例如String Pool
(用于高度优化的字符串相等性测试),通常由String 创建.intern() 方法。
随着您的应用程序(类数量)的增长,该空间将很快被填满,因为该空间上的垃圾收集对于按要求进行清理并不有效,您很快就会出现“内存不足:永久生成空间”错误。 此后,即使有一个巨大的空 JVM,任何应用程序都无法在该机器上有效运行。
在启动应用程序之前,您应该使用
java -XX:MaxPermSize
来消除此错误。Perm space
is used to keep informations for loaded classes and few other advanced features likeString Pool
(for highly optimized string equality testing), which usually get created byString.intern()
methods.As your application(number of classes) will grow this space shall get filled quickly, since the garbage collection on this Space is not much effective to clean up as required, you quickly get Out of Memory : perm gen space error. After then, no application shall run on that machine effectively even after having a huge empty JVM.
Before starting your application you should
java -XX:MaxPermSize
to get rid of this error.简单(而且过于简单)的答案:这是 jvm 存储自己的簿记数据的地方,而不是你的数据。
Simple (and oversimplified) answer: it's where the jvm stores its own bookkeeping data, as opposed to your data.
Perm Gen 代表永久生成,它保存有关类的元数据信息。
Perm Gen stands for permanent generation which holds the meta-data information about the classes.
永久代空间是堆中保存虚拟机本身所有反射数据的区域,例如类和方法对象。
The permgen space is the area of heap that holds all the reflective data of the virtual machine itself, such as class and method objects.
它包含类定义、字符串池等内容。我想你可以称之为元数据。
It holds stuff like class definitions, string pool, etc. I guess you could call it meta-data.
PermGen 空间通常被称为方法区。当类加载器子系统将类文件(字节代码)加载到方法区(permGen)时。
它包含所有类元数据,例如:类的完全限定名称、直接父类的完全限定名称、变量信息、构造函数信息、常量池信息等。
Permgen space is always known as method area.When the classloader subsystem will load the the class file(byte code) to the method area(permGen).
It contains all the class metadata eg: Fully qualified name of your class, Fully qualified name of the immediate parent class, variable info, constructor info, constant pool infor etc.
PremGen 下存在什么:类区域属于 PremGen 区域。 静态字段也是在类加载时开发的,因此它们也存在于 PremGen 中。 常量池区域保存了所有像字符串一样池化的不可变字段。 除此之外,还定位了类加载器加载的类数据、对象数组、jvm 使用的内部对象。
What exists under PremGen : Class Area comes under PremGen area. Static fields are also developed at class loading time, so they also exist in PremGen. Constant Pool area having all immutable fields that are pooled like String are kept here. In addition to that, class data loaded by class loaders, Object arrays, internal objects used by jvm are also located.
PermGen Space 代表永久生成的内存分配 所有 Java 不可变对象都属于此类别,例如使用文字或使用 String.intern() 方法创建并用于加载的
String
将课程放入内存中。 PermGen Space 加速了我们的字符串相等性搜索。PermGen Space stands for memory allocation for Permanent generation All Java immutable objects come under this category, like
String
which is created with literals or withString.intern()
methods and for loading the classes into memory. PermGen Space speeds up our String equality searching.存储在堆中(年轻代或终身代)。
存储在永久生成
are stored in the heap (in the young generation or the tenured generation).
are stored in the permanent generation