CSc 520 - Principles of Programming Languages
9 : Memory Management -- GC -- Copying Collection

Christian Collberg

Department of Computer Science

University of Arizona

1 Copying Collection

2 Copying Collection...

3 Copying Collection...

4 Copying Collection...

Algorithm:
  1. Start allocating in from-space.
  2. When from-space is full, copy live objects to to-space.
  3. Now allocate in to-space.

5 Copying Collection...

Traversing the Object Graph:

Updating (Forwarding) Pointers:

Example:

CopyingCollection0

6 Copying Collection Algorithm

  1. scan := next := ADDR(to-space)
  2. Copy objects pointed to by the root pointers to to-space.
  3. Update the root pointers to point to to-space.
  4. Put each object's new address first in the original.
  5. Repeat (recursively) with all the pointers in the new to-space.
    1. Update scan to point past the last processed node.
    2. Update next to point past the last copied node.
    Continue while scan < next.

7 Copying Collection Example...(A)

CopyingCollection1

8 Copying Collection Example...(B)

CopyingCollection2


Cost of Garbage Collection


9 Cost of Garbage Collection

GCCost1

6#6

10 Cost of GC -- Copying Collection

GCCost-Copy


11#11

11 Cost of GC -- Copying Collection...

GCCost-Copy-FewLive

12 Readings and References



Christian Collberg 2008-02-11