Java / JVM Architecture (Java21) Interview questions
What is the Heap memory in JVM?
The Heap is the shared runtime area where every object and array created with new actually lives, regardless of which thread created it.
It is divided generationally into a Young Generation (Eden plus two Survivor spaces) for newly created objects, and an Old (Tenured) Generation for objects that have survived enough garbage collection cycles.
Heap size is controlled with -Xms (initial size) and -Xmx (maximum size), and the heap is the primary target of the garbage collector, since objects here are the ones eligible to be reclaimed once unreachable.
More Related questions...