يدير 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+)
