Where methods live? Stack or in Heap?

前端 未结 6 415
攒了一身酷
攒了一身酷 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:02

    The stack contains all the local variables and all active method invocations. The heap hold everything else.

    As for your sub question: it means a new stack is created with its own dedicated memory. While your new thread will share the total heap space (memory) allocated by the jvm

提交回复
热议问题