GC Algorithm inside .NET<br />Luo Bingqiao<br />5/22/2009<br />
Agenda<br />经典基本垃圾回收算法<br />CLR中垃圾回收算法介绍<br />SSCLI中Garbage Collection源码分析<br />
经典基本垃圾回收算法<br />Reference Counting算法<br />Mark-Sweep与Mark-Sweep-Compact算法<br />Copying 算法<br />
Reference Counting算法<br />Storing the Number of reference, Pointers, and resource such<br />as an Object or Memory block.<...
Deferred reference counting
One-bit reference counting
Weighted reference counting</li></li></ul><li>Reference Counting算法<br />Advantages and Disadvantages<br /><ul><li>Reclaim ...
Difficult to resolve circular references </li></ul>Examples of Use:<br /><ul><li>COM, Cocoa, Delphi, PHP, Python</li></li>...
At some stage, mark the objects that are dead and can be removed
Free the dead object slots at some stage </li></li></ul><li>Mark-Sweep<br />Advantages and Disadvantages<br /><ul><li>Mini...
Every allocation request requires a walk thru the free list, makes allocations slow
Heap fragmentation </li></ul>Examples of Use:<br /><ul><li>C Runtime Heap, .NET Micro Framework</li></li></ul><li>Copy and...
Allocate only from one heap
When collection is triggered on the heap, copy all alive objects to the second heap
Switch the roles of heaps </li></li></ul><li>Copy and Collect<br />Advantages and Disadvantages<br /><ul><li>Conceptual Si...
Copy operation needs to be done for all objects
Blocks a lot of memory unnecessarily </li></li></ul><li>What happens in CLR and JVM?<br />
GC Algorithms in advanced OO language VMS<br /><ul><li>Mark Sweep Compact / Train algorithm
Generational incremental Collector
Upcoming SlideShare
Loading in...5
×

Gc algorithm inside_dot_net

1,160

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,160
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Gc algorithm inside_dot_net

  1. 1. GC Algorithm inside .NET<br />Luo Bingqiao<br />5/22/2009<br />
  2. 2. Agenda<br />经典基本垃圾回收算法<br />CLR中垃圾回收算法介绍<br />SSCLI中Garbage Collection源码分析<br />
  3. 3. 经典基本垃圾回收算法<br />Reference Counting算法<br />Mark-Sweep与Mark-Sweep-Compact算法<br />Copying 算法<br />
  4. 4. Reference Counting算法<br />Storing the Number of reference, Pointers, and resource such<br />as an Object or Memory block.<br /><ul><li>Simple reference counting
  5. 5. Deferred reference counting
  6. 6. One-bit reference counting
  7. 7. Weighted reference counting</li></li></ul><li>Reference Counting算法<br />Advantages and Disadvantages<br /><ul><li>Reclaim objects promptly
  8. 8. Difficult to resolve circular references </li></ul>Examples of Use:<br /><ul><li>COM, Cocoa, Delphi, PHP, Python</li></li></ul><li>Mark-Sweep<br /><ul><li>Initially, allocate objects on the heap sequentially
  9. 9. At some stage, mark the objects that are dead and can be removed
  10. 10. Free the dead object slots at some stage </li></li></ul><li>Mark-Sweep<br />Advantages and Disadvantages<br /><ul><li>Minimal house-keeping overhead (just one free list)
  11. 11. Every allocation request requires a walk thru the free list, makes allocations slow
  12. 12. Heap fragmentation </li></ul>Examples of Use:<br /><ul><li>C Runtime Heap, .NET Micro Framework</li></li></ul><li>Copy and Collect<br /><ul><li>Keep two heaps
  13. 13. Allocate only from one heap
  14. 14. When collection is triggered on the heap, copy all alive objects to the second heap
  15. 15. Switch the roles of heaps </li></li></ul><li>Copy and Collect<br />Advantages and Disadvantages<br /><ul><li>Conceptual Simplicity
  16. 16. Copy operation needs to be done for all objects
  17. 17. Blocks a lot of memory unnecessarily </li></li></ul><li>What happens in CLR and JVM?<br />
  18. 18. GC Algorithms in advanced OO language VMS<br /><ul><li>Mark Sweep Compact / Train algorithm
  19. 19. Generational incremental Collector
  20. 20. Large Object Heap
  21. 21. Segments
  22. 22. Finalization in CLR
  23. 23. Weak References
  24. 24. Pinning
  25. 25. Object Layout </li></li></ul><li>Heap Organization<br />Heap organization for the train algorithm.<br />
  26. 26. Overall of GC Algorithm<br />
  27. 27. Mark Phase:<br />
  28. 28. Mark Phase<br />Separate the live objects from dead objects for the<br />generation being collected. <br /><ul><li>All small dead objects have their Mark bit set, and if required Pin bit also set
  29. 29. Finalizable objects are put on the FReachable queue
  30. 30. Weak pointers to dead objects are nulled
  31. 31. All large dead objects are put on the FreeList</li></li></ul><li>Sweep Phase:<br />Put all dead objects on a free list<br />
  32. 32. Managed Heap after Compact:<br />
  33. 33. Finalization Internals <br />
  34. 34. More Information<br />External<br />ISMM forum<br /><<Garbage Collection>>, Algorithms for automatic Dynamic Memory managements<br />Email<br />lbq1221119@hotmail.com<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×