1 / 16

Overview

Overview. Assignment 6: hints Living with a garbage collector Assignment 5: solution Garbage collection. Ex1– Memory Allocation in .NET. Object F. Object E. Object D. NextObjPtr. Object C. Object B. Object A. Mark Phase. NextObjPtr. Object F. ROOTS globals locals registers.

iliana
Download Presentation

Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Overview • Assignment 6: hints • Living with a garbage collector • Assignment 5: solution • Garbage collection

  2. Ex1– Memory Allocation in .NET Object F Object E Object D NextObjPtr Object C Object B Object A

  3. Mark Phase NextObjPtr Object F ROOTS globals locals registers Object E Object D Object C Object B Object A

  4. Copy Phase NextObjPtr Object F ROOTS globals locals registers Object E Object D Object C Object B Object A

  5. Finalizers public class MyClass { public override void Finalize() { // Clean up the object } }

  6. Finalizers Finalization Queue Object A NextObjPtr Object F Object F ROOTS globals locals registers Object E Freachable Queue Object D Object C Object B Object A

  7. Finalizers in the .Net system • Why finalize methods are not executed by the GC? • How to resuscitate objects in their finalizer method? • Does the execution order of the finalizers matter?

  8. A6 Ex2 – Generations NextObjPtr Object J Object I Gen 0 Object H Object L Object G Object F Object E Gen 1 Object D Object C Object B Object A

  9. Generations / Write Barriers The compiler instruments the code to implement a write barrier. • Think of a more efficient implementation of a write barrier.

  10. A6 Ex3– Weak Pointers (.Net) NextObjPtr Object F ROOTS globals locals registers Object E Weak Pointer Tables Object D Object C Object B Object F Object A

  11. A6 – Weak Pointers • Weak pointers in .NET: • users have to check if a weak pointer is still valid. • Weak pointers in Java and Python • users can be notified when a weak pointer is invalidated. • Advantages / disadvantages? • Examples?

  12. Overview • Assignment 6: hints • Living with a garbage collector • Assignment 5: solution • Garbage collection

  13. A5 Ex1 - Barriers p.next = q Read barrier: if pointer is forwarding follow the forwarding load pointer read write Write barrier: if p is black & q not black mark p gray write pointer

  14. A5 Ex1 - Barriers • Which barrier to use for: • Incremental copying GC • Read and write barriers • Mark & Sweep GC • No barriers

  15. A5 Ex2 – Copying collectors • How to solve the movement problem for the compacting and copying GC. • Copying GC: obj. moved to to-space, install forwarding pointer, update other pointers on forwarding pointer read. • Compacting GC: update pointers after mark, before the move operation.

  16. A5 Ex2 – Copying collectors Mark & Sweep vs. Copying GCs: • Which collector has the fastest allocation? • M&S: traverse the list of free blocks • Copying: just allocate on top of the other objects (O(1)) • Give an estimate of the collection cycle cost (M = heap size, R = live objects) • M&S: R to mark, M to sweep  R + M • Copying: move R objects  R

More Related