6.001 Recitation – May 9,
2003
RI: Konrad
Tollmar
• Memory
Management
• Decompiling
1. Store lists in arrays
A/ Draw the box-and-pointer diagram starting from P5
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Cars |
N3 |
N4 |
P0 |
N3 |
N5 |
P2 |
N2 |
N3 |
P1 |
N4 |
|
Cdrs |
E0 |
E0 |
P4 |
P5 |
P0 |
P6 |
P5 |
P3 |
P3 |
N5 |
|
B / Save foo in memory
(define foo
(map square (list 1 2 3)))
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Cars |
|
|
|
|
|
|
|
|
|
|
|
Cdrs |
|
|
|
|
|
|
|
|
|
|
|
2. GC – Stop & Copy
Do stop-and-copy on the following with Root Set = { P5 }:
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Cars |
N3 |
N4 |
P0 |
N3 |
N5 |
P2 |
N2 |
N3 |
P1 |
N4 |
|
Cdrs |
E0 |
E0 |
P4 |
P5 |
P0 |
P6 |
P5 |
P3 |
P3 |
N5 |
|
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Cars |
|
|
|
|
|
|
|
|
|
|
|
Cdrs |
|
|
|
|
|
|
|
|
|
|
|
3. GC – Mark & Sweep
Do the mark & sweep on the following with Root Set = { P5 }:
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
Cars |
N3 |
N4 |
P0 |
N3 |
N5 |
P2 |
N2 |
N3 |
P1 |
N4 |
|
Cdrs |
E0 |
E0 |
P4 |
P5 |
P0 |
P6 |
P5 |
P3 |
P3 |
N5 |
|
|
|
|
|
|
|
|
|
|
|
|
|