Java interfaces… Dynamic or static memory?

后端 未结 3 1373
北恋
北恋 2021-01-19 15:10

Where do java interfaces reside in memory? Do they reside in the heap or the stack, or maybe global memory? I am thinking the are in the stack since they are created at comp

相关标签:
3条回答
  • 2021-01-19 15:32

    Class definitions -- including interfaces and abstract classes -- are held in PermGen space, meaning they are never garbage collected. The PermGen is, iirc, a part of the heap.

    0 讨论(0)
  • 2021-01-19 15:37

    Class definitions (including interfaces, etc) are stored on the heap (usually in the Permanent generation because their lifetime is long). If the ClassLoader that created them is garbage collected, they too are then eligible for garbage collection.

    0 讨论(0)
  • 2021-01-19 15:48

    Interfaces are technically not "instantiated" in the sense that a regular class instance is created, but class information is stored in the java permgen space. See http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation for more information on the permgen and the difference between a class instance and class information.

    0 讨论(0)
提交回复
热议问题