JVM ਆਟੋਮੈਟਿਕ ਤੌਰ 'ਤੇ ਮੈਮੋਰੀ ਨੂੰ ਮੈਨੇਜ ਕਰਦਾ ਹੈ — ਆਬਜੈਕਟਸ ਨੂੰ ਅਲਾਕੇਟ ਕਰਦਾ ਹੈ ਅਤੇ ਗਾਰਬੇਜ ਕਲੇਕਸ਼ਨ (GC) ਦੁਆਰਾ ਅਣਪਹੁੰਚਯੋਗ ਦੀਆਂ ਚੀਜਾਂ ਨੂੰ ਖਾਲੀ ਕਰਦਾ ਹੈ — ਤਾਂ ਜੋ ਤੁਹਾਨੂੰ ਮੈਮੋਰੀ ਦੀ ਮੈਨੁਅਲ ਤੌਰ 'ਤੇ ਖਾਲੀ ਕਰਨ ਦੀ ਲੋੜ ਨਾ ਪਵੇ। ਮੈਮੋਰੀ ਖੇਤਰਾਂ ਅਤੇ GC ਵਤੀਰੇ ਨੂੰ ਸਮਝਣਾ ਪਰਫਾਰਮੈਂਸ ਟਿਊਨਿੰਗ ਅਤੇ ਮੈਮੋਰੀ ਮੁੱਦਿਆਂ ਦਾ ਨਿਦਾਨ ਕਰਨ ਲਈ ਮਹੱਤਵਪੂਰਨ ਹੈ।
JVM ਮੈਮੋਰੀ ਖੇਤਰ
text
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+)
