Mastering Java Memory Management and Garbage Collection
Mastering Java Memory Management and Garbage Collection
PRITAM CHAKRABORTY
Memory STREAM- CSE
SECTION- A
Management and ROLL NUMBER-
12100122045
Garbage Collection
TOPICS
that books are efficiently stored and removed
when no longer needed.
The Java
Memory Model
• Stack Memory
• Heap Memory
Stack
JAVA
Memory
allocated to each thread at run time
Memory
application as long as the application runs.
Tip: GC is like a janitor in our memory warehouse, cleaning up unneeded items to make space for new ones.
Garbage Collection
(GC) Key Concepts
Introduction of Java 1.4 and .NET Java 7 introduced the G1 Java 11 introduced ZGC
generational garbage Framework adopted Garbage Collector, and Shenandoah GC,
generational GC, with enhancing generational focusing on reducing
collection concepts,
Java's HotSpot JVM GC with low-latency pause times and
focusing on separating
implementing young and optimizations. improving performance
objects by age to
old generations, while incorporating
improve memory and .NET using three generational GC
management. generations (0, 1, and principles
2).
Young • Young Generation GC focuses on
collecting short-lived objects, initially
allocated in the Eden space and moved
Generation GC to Survivor spaces.
Avoid Memory Leaks Use Weak References: Optimize Garbage Collection: Profile Memory Usage:
Minimize Object Retention: Prefer Stack Allocation: Limit Thread Count: Optimize Data Structures:
Resources
essential concepts.