1
Java Memory and Garbage Collection
Java
- Stack โ method calls and local variables, one per thread.
- Heap โ all objects; shared by threads; divided into Young generation (Eden, Survivor) and Old generation.
- Method area / Metaspace โ class metadata and static variables.
- An object becomes eligible for GC when no reference points to it.
System.gc()is only a request.