Java Core Flashcards
Types of Memory in Java
5 Types: Class(Method) Area Heap Stack Program Counter Register Native Method Stack
Class Method Area
This part of the JVM memory area is shared by all executing threads.
Class elements like constant pool, class fields, constructor codes, method codes, etc.
Method area can be considered as a part of the heap area but stores per-class data only.
We can say that the method area is responsible for holding class level information.
Heap Memory
Heap Memory in java is used by java runtime to allocate memory to objects and class during the execution of a java program.
Whenever an object is created in java, it gets stored into heap memory.
A Process called garbage collection runs on heap memory to free up unnecessary space that is garbage collection removes those objects from the heap area which does not have any references