Understanding Java Garbage Collection (1) - Watermark (1) - Watermark
Understanding Java Garbage Collection (1) - Watermark (1) - Watermark
314CS23078
V. Common Algorithms
• Mark-and-Sweep: This traditional algorithm involves two phases:
– Mark Phase: It traverses from the root set and marks all
reachable objects.
– Sweep Phase: Once the marking is complete, it scans through
the heap memory and de-allocates the memory occupied by
unmarked objects.
• Generational Garbage Collection: This algorithm is based on the
observation that most objects have a short lifespan. It divides the heap
into different generations (Young, Old, and Permanent).
– Young Generation: Objects are allocated here. After a minor
garbage collection, surviving objects are promoted to the Old
Generation.
– Old Generation: Objects that have survived several collections.
Major garbage collection happens less frequently in this area.
These algorithms not only aid in identifying and reclaiming non-used memory
but also enhance the overall performance and efficiency of Java applications
by minimizing pauses during execution.
314CS23078
– Suitable for applications that require significant computing power.
• Weaknesses: Higher complexity in implementation, potential for
increased resource usage.
314CS23078
3. Enhanced Application Performance
• Optimal Resource Utilization: By efficiently managing memory,
garbage collection contributes to smoother application execution,
reducing latency and improving responsiveness.
Overall, these advantages make garbage collection a crucial feature in Java,
streamlining development processes and ensuring robust application
performance.
314CS23078