Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Gc algorithm inside_dot_net

1 572 vues

Publié le

Publié dans : Technologie
  • Soyez le premier à commenter

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 />