java - 堆的 PermGen 空间

标签 java permgen

image所示, Permgen又分为几个部分。

enter image description here

Runtime constant pool stores constants pertaining to each type that is loaded by class loader.

Method area stores method information such as method return type, method name. (correct me if I am wrong here.)

And Reserved area is the part which is reserved if more memory is required by permgen.

但是我不明白的是,图像中的代码区域是什么?任何代码都存储在这个空间中(我觉得很模糊)?

最佳答案

Any code is stored in this space(seems vague to me)?

有什么具体原因吗?

可能的答案可能是:代码区存储加载到内存中的类的字节码。

但是问题来了,为什么class不直接加载到RAM中?

因为我们有一个 JVM 来提供互操作性,因为 JVM 是 java 代码和机器之间的中介,所以我们需要一些地方来存储代码语句,直到 JVM 被 OS 调度来执行它的代码。(对于 OS JVM 是一个过程)。因此,它将字节代码加载到代码区域(如果我是对的),并在计划时进一步将代码(.class)解释为底层机器指令。

给我的答案是“代码区保存类的字节码”。

为了支持上述想法,这里有一些概念是从 Oracle blog 复制而来的。其中说:

So the Java classes are stored in the permanent generation. What all does that entail? Besides the basic fields of a Java class there are:

  1. Methods of a class (including the bytecodes)
  2. Names of the classes (in the form of an object that points to a string also in the permanent generation)
  3. Constant pool information (data read from the class file, see chapter 4 of the JVM specification for all the details).
  4. Object arrays and type arrays associated with a class (e.g., an object array containing references to methods).
  5. Internal objects created by the JVM (java/lang/Object or java/lang/exception for instance)
  6. Information used for optimization by the compilers (JITs)

希望一切顺利。

关于java - 堆的 PermGen 空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20119478/

相关文章:

java - Web 应用程序类路径和类加载到堆中

function - 在 JVM 中分配大量 PermGen 空间时,Scala 中的一等函数能否成为一个问题?

java - 为什么 PermSize 和 MaxPermSize 的设置值和实际值不同?

c# - .NET 有类似 Java 的 permgen 的东西吗?

java - "No GC root found"时 PermGen OutOfMemoryError 的原因?

java - 事务回滚后,Spring 不会关闭 hibernate session

java - 在java中,当a.b都是整数时,a-b>0和a>b是否有可能不同?

java - 如何从方法的输入生成 sql

java - 使用 Java 中的命令行和外部 Jars 编译多个包

apache - 启动时 Apache Tomcat 中的 PS Permgen 为 98%