Is the Java .class file stored in JVM memory

2020-04-08 13:05发布

I read on the JVM memory model and got confused with the follows:

  1. Does the JVM store the .class instance in its memory. 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.
  3. The perm gen etc areas store the byte code or the machine level code?
  4. perm gen vs method area

I would really appreciate any help on the topic.

Thanks.

标签: java jvm
2条回答
Viruses.
2楼-- · 2020-04-08 13:47

Does the JVM store the .class instance in its memory.If yes then in which area

PermGen

Is it like as soon as the class is loaded

You can load the class without reading the .class

,the JVM generated machine level code and then starts executing the machine code instructions

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?

Both. They are inseparable.

查看更多
太酷不给撩
3楼-- · 2020-04-08 14:11

1) .class file will be store in permgen memory area on load.

2) Objects on HEAP will be created while program run, when you explicitly create, not on load. 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. 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.

查看更多
登录 后发表回答