Java - Memory Allocation for Classes
Where is the definition of class 开发者_如何学运维stored in memory ?
It depends on which Java you're talking about
"the memory layout of run-time data areas, the garbage-collection algorithm used, and any internal optimization of the Java virtual machine instructions (for example, translating them into machine code) are left to the discretion of the implementor."
See the JVM spec.
That said, Sun Java has a section of memory called the permanent generation, which includes class definitions. Because of its original intent (a relatively small area for mostly static classes), the permanent generation doesn't always fit well with dynamic langauges targetting the JVM. See this discussion of JRuby issues. That is part of the motivation for the Da Vinci Machine project, which aims to improve VM support for such languages.
精彩评论