5. Why do I need to know about GC?
Because GC stops your application!
6.
7. Why to collect garbage?
●
Limited storage
●
Programmers do not like to get dirty
●
Programmers make mistakes
–
Too little collected – memory leaks – error
–
Too much collected – broken programs – error
●
Programmers like good software design
–
Explicit memory management conflicts with the software
engineering principles of abstraction and modularity
35. Detecting dead objects
●
Reference tracing
✔ No mutator overhead
✔ Collect cycles
✔ High throughput
✗ Batch style
✗ Not real time
●
Reference counting
✔ Incremental
✔ Short pause
✔ Real time
✗ Reference cycles
✗ High mutator overhead
✗ Low throughput
43. Copying GC (Survivor spaces)
Eden From To
Eden From To
Eden From To
Eden From To
44. Copying GC (Survivor spaces)
Eden From To
Eden To From
Eden To From
Eden From To
45. Copying GC
✔ Compacted heap
✔ The speed depends on
the number of live
objects
✔ Possible improvement of
locality during
evacuation
✗ Space overhead
46. Generational hypothesis
Weak generational hypothesis is the
observation that, in most cases, young objects
are much more likely to die than old objects.
Conversely any object that has survived several
GC cycles will probably survive a lot more.
50. Card Table and Remembered Set
Young space Old space
Card Table
Dirty
Dirty card – write to memory – possible reference to young generation.
Will be added to Remembered Set
53. Thread Local Allocation Buffer
●
Thread allocates within TLAB using bump the pointer
●
Improved objects locality
●
No contention single pointer
TLAB
54. Promotion Local Allocation Buffer
Each thread has two PLABs:
• One for survivor space,
• One for tenured space
PLAB1 PLAB2
GC Thread 1
GC Thread 2
56. Real-time GC
Real-time systems impose operational deadlines
on particular tasks within an application. These
real-time tasks must be able to response to
application inputs (events) within a fixed time
window.
The Garbage Collection Handbook – Jones, Hosking, Moss