gpt4 book ai didi

java - 堆的 PermGen 空间

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:26:50 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com