Sobes.tech
Junior — Middle

Where in JVM memory are static class methods placed?

sobes.tech AI

Answer from AI

In the JVM, static methods of classes are placed in a memory area called Metaspace (starting from Java 8). Previously, in versions before Java 8, PermGen was used for this purpose.

Metaspace stores class metadata, including information about static methods, fields, constants, and class structure. When a class is loaded into the JVM, its static methods are loaded into this area, allowing the JVM to invoke them without creating an instance of the class.

Thus, static methods are not placed in the heap or stack but in a special metadata area — the metaspace.