The JVM allocates these areas in memory: Class(Method) Area, Heap, Stack, Program counter Register, Native method stack.
I know that heap is used to store objects and stack is used to store local variables and partial results. According to definition, Class(Method) Area stores per-class structures such as the runtime constant pool, field and method data, the code for methods. But I really don't understand the difference.
Can anyone please explain the difference between Class area and Heap?
Java 6 stores all the constant pool and Class information in the Perm Gen
Java 7 only stores the class information in the Perm Gen. The String literal pool is on the heap.
Java 8 has no Perm Gen. The literal pools and class information are on the heap.
You have explained the difference. Class structures like methods are stored in perm gen. The data in each instance is stored in the heap.
They were separated as these types of data have very different lifecycles e.g. Objects are typically short lived and classes are typically very long lived.
AFAIK They are removing it because too many developers found it confusing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With