JVM સ્વચાલિત રીતે મેમરી સંચાલે છે — પદાર્થોને বরাદ્દ કરે છે અને કચરો સંગ્રહ (GC) દ્વારા અપ્રાપ્ય લોકોને મુક્ત કરે છે — તેથી તમે મેમરીને મેમોરીથી મુક્ત કરવાની જરૂર નથી. મેમરી ક્ષેત્રો અને GC વર્તણૂક સમજવું કામગીરી ટ્યુન કરવા અને મેમરી સમસ્યાઓનું નિદાન કરવા માટે મહત્વપૂર્ણ છે.
JVM મેમરી ક્ષેત્રો
HEAP — where all OBJECTS live (shared across threads), GC operates here
├── Young Generation — new objects (most die young)
│ ├── Eden — new allocations go here
│ └── Survivor — objects that survived a young GC
└── Old (Tenured) Gen — long-lived objects (promoted from young)
STACK — per-thread; method frames, local variables, primitive locals, references
Metaspace — class metadata (replaced PermGen in Java 8+)
