简体   繁体   English

Java .class文件是否存储在JVM内存中

[英]Is the Java .class file stored in JVM memory

I read on the JVM memory model and got confused with the follows: 我读了JVM内存模型,并对以下内容感到困惑:

  1. Does the JVM store the .class instance in its memory. JVM是否将.class实例存储在其内存中。 If yes then in which area. 如果是,则在哪个区域。
  2. Is it like as soon as the class is loaded,the JVM generated machine level code and then starts executing the machine code instructions and then only the objects are created on heap and method area is populated. 就像加载类一样,JVM生成机器级代码然后开始执行机器代码指令,然后只在堆上创建对象并填充方法区域。
  3. The perm gen etc areas store the byte code or the machine level code? perm gen等区域存储字节代码或机器级代码?
  4. perm gen vs method area perm gen vs方法区域

I would really appreciate any help on the topic. 我真的很感激有关该主题的任何帮助。

Thanks. 谢谢。

1) .class file will be store in permgen memory area on load. 1) .class文件将在加载时存储在permgen内存区域中。

2) Objects on HEAP will be created while program run, when you explicitly create, not on load. 2)HEAP上的对象将在程序运行时创建,当您明确创建时,而不是在加载时。 The JVM compiles methods 'lazily', that is it emits small stubs in place of the compiled machine code of the method that will trigger the compilation of each method. JVM编译方法'懒惰',即它发出小的存根来代替方法的编译机器代码,这将触发每个方法的编译。 This means that methods that are not used are never compiled. 这意味着永远不会编译未使用的方法。

3) perm gen stores bytes code (.class file will be loaded), not sure about machine level code. 3)perm gen存储字节代码(将加载.class文件),不确定机器级代码。

Does the JVM store the .class instance in its memory.If yes then in which area JVM是否将.class实例存储在其内存中。如果是,则在哪个区域中

PermGen PermGen的

Is it like as soon as the class is loaded 这个类加载后是否就像它一样

You can load the class without reading the .class 您可以在不读取.class情况下加载该类

,the JVM generated machine level code and then starts executing the machine code instructions ,JVM生成机器级代码,然后开始执行机器代码指令

The byte code is interpreted or potentially compiled to native machine code some time later. 一段时间后,字节代码被解释或可能编译为本机机器代码。

The perm gen etc areas store the byte code or the machine level code? perm gen等区域存储字节代码或机器级代码?

Both. 都。 They are inseparable. 他们是不可分割的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM