Where methods live? Stack or in Heap?

前端 未结 6 428
攒了一身酷
攒了一身酷 2020-12-14 13:16

I know that local variables and paramters of methods live in stack, but I not able to figure out where does actually methods live in case of Java?

If I declare any T

6条回答
  •  遥遥无期
    2020-12-14 14:14

    The heap is split up into multiple generations.

    The bytecode, and its corrosponding JIT compiled machine code lives in the so called permanent generation, along with interned Strings and other class data.

    Even though it is called the "permanent" generation, it can still be garbage collected. Some libraries, frameworks and JVM languages generate bytecode at run-time, so the permanent generation sometimes need clean up. Just like the other generations of the heap, but (one usually hopes) less frequently.

提交回复
热议问题