Java Memory Management
9 lessons in this section of the Java tutorial. Work through them in order, or jump to the one you need.
- 1.Stack Memory
Stack memory is the region of memory where the JVM stores method invocation frames, local variables, and partial results.
- 2.Heap Memory
The heap is the runtime data area from which all Java object instances and arrays are allocated.
- 3.Metaspace
Metaspace is the JVM memory region that stores class metadata — the internal representations of loaded classes, methods, fields, constant pools, and annotations.
- 4.JVM Memory Model
The JVM Memory Model encompasses two related but distinct concepts.
- 5.Garbage Collection
Garbage collection is the automatic process by which the JVM reclaims memory occupied by objects that are no longer reachable from the running program.
- 6.GC Algorithms
Garbage collection algorithms are the strategies the JVM uses to identify and reclaim unreachable objects.
- 7.Memory Leak
A memory leak in Java occurs when objects that are no longer needed by the application remain reachable through strong references, preventing the garbage collector from…
- 8.finalize()
The finalize() method was a mechanism for performing cleanup on objects before they were garbage collected.
- 9.Reference Types (Weak, Soft, Phantom)
Java provides four reference strengths beyond the ordinary strong reference: strong (the default), soft, weak, and phantom.