Java Interfaces ... Dynamic or Static Memory?

Where are the java interfaces in memory? Are they on the heap or the stack, or maybe in global memory? I think they are on the stack since they are created at compile time. Am I right?

+4
source share
3 answers

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

+5
source

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

+1
source

Class definitions (including interfaces, etc.) are stored on the heap (usually in the constant generation, because their lifespan is long). If the ClassLoader they ClassLoader is garbage collection, then they also have the right to garbage collection.

0
source

Source: https://habr.com/ru/post/1302149/


All Articles