Date post: | 06-Apr-2018 |
Category: |
Documents |
Upload: | benjamin-tan |
View: | 234 times |
Download: | 0 times |
of 116
8/3/2019 Copying Gc
1/116
Copying Garbage Collection
Guido Tack14. November 2001
8/3/2019 Copying Gc
2/116
1 The idea of Copying GC
Two semi-spaces (From-space and To-space) Only From-space active
At GC time, copy the live nodes from From-Space to To-Space
Then flip the spaces
8/3/2019 Copying Gc
3/116
1 The idea of Copying GC
Two semi-spaces (From-space and To-space)
Only From-space active
At GC time, copy the live nodes from From-Space to To-Space
Then flip the spaces
8/3/2019 Copying Gc
4/116
1 The idea of Copying GC
Two semi-spaces (From-space and To-space)
Only From-space active
At GC time, copy the live nodes from From-Space to To-Space
Then flip the spaces
8/3/2019 Copying Gc
5/116
1 The idea of Copying GC
Two semi-spaces (From-space and To-space)
Only From-space active
At GC time, copy the live nodes from From-Space to To-Space
Then flip the spaces
8/3/2019 Copying Gc
6/116
1 The idea of Copying GC
Two semi-spaces (From-space and To-space)
Only From-space active
At GC time, copy the live nodes from From-Space to To-Space
Then flip the spaces
8/3/2019 Copying Gc
7/116
2 Before GC
A
D E F
G
CB
From
To
8/3/2019 Copying Gc
8/116
3 After GC
To
B CA D E
F G
A
D E F
G
CB
From
8/3/2019 Copying Gc
9/116
4 Cheneys algorithm(1)
Iterative algorithm
Interleaves copying and scanning
Two pointers needed: scan / free
Forwarding pointers used to preserve sharing
8/3/2019 Copying Gc
10/116
8/3/2019 Copying Gc
11/116
4 Cheneys algorithm(1)
Iterative algorithm
Interleaves copying and scanning
Two pointers needed: scan / free
Forwarding pointers used to preserve sharing
8/3/2019 Copying Gc
12/116
4 Cheneys algorithm(1)
Iterative algorithm
Interleaves copying and scanning
Two pointers needed: scan / free
Forwarding pointers used to preserve sharing
8/3/2019 Copying Gc
13/116
4 Cheneys algorithm(1)
Iterative algorithm
Interleaves copying and scanning
Two pointers needed: scan / free
Forwarding pointers used to preserve sharing
8/3/2019 Copying Gc
14/116
5 Cheneys algorithm(2)
Tricolour abstraction:
Black nodes: GC finished, not to be considered again
Grey nodes: Visited but not completed
White nodes: Unvisited, considered garbage after tracing
GC terminates when all reachable nodes are black
8/3/2019 Copying Gc
15/116
5 Cheneys algorithm(2)
Tricolour abstraction:
Black nodes: GC finished, not to be considered again
Grey nodes: Visited but not completed
White nodes: Unvisited, considered garbage after tracing
GC terminates when all reachable nodes are black
8/3/2019 Copying Gc
16/116
5 Cheneys algorithm(2)
Tricolour abstraction:
Black nodes: GC finished, not to be considered again
Grey nodes: Visited but not completed
White nodes: Unvisited, considered garbage after tracing
GC terminates when all reachable nodes are black
8/3/2019 Copying Gc
17/116
5 Cheneys algorithm(2)
Tricolour abstraction:
Black nodes: GC finished, not to be considered again
Grey nodes: Visited but not completed
White nodes: Unvisited, considered garbage after tracing
GC terminates when all reachable nodes are black
8/3/2019 Copying Gc
18/116
5 Cheneys algorithm(2)
Tricolour abstraction:
Black nodes: GC finished, not to be considered again
Grey nodes: Visited but not completed
White nodes: Unvisited, considered garbage after tracing
GC terminates when all reachable nodes are black
8/3/2019 Copying Gc
19/116
5 Cheneys algorithm(2)
Tricolour abstraction:
Black nodes: GC finished, not to be considered again
Grey nodes: Visited but not completed
White nodes: Unvisited, considered garbage after tracing
GC terminates when all reachable nodes are black
8/3/2019 Copying Gc
20/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
21/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
22/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
23/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
24/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
25/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
26/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
27/116
A
D E F
G
CB
F
rom
To
scan
free
8/3/2019 Copying Gc
28/116
A
D E F
G
CB
F
rom
To
A
A
scan
free
8/3/2019 Copying Gc
29/116
A
D E F
G
CB
F
rom
To
A
A
scan
free
8/3/2019 Copying Gc
30/116
A
D E F
G
CB
F
rom
To
A
A
scan
free
8/3/2019 Copying Gc
31/116
A
D E F
G
CB
F
rom
To
A
A
scan
free
8/3/2019 Copying Gc
32/116
A
D E F
G
CB
F
rom
To
A
A
scan
free
8/3/2019 Copying Gc
33/116
A
D E F
G
CB
F
rom
To
A
A
scan
free
8/3/2019 Copying Gc
34/116
A
D E F
G
CB
F
rom
To
A
A
B
B
free
scan
8/3/2019 Copying Gc
35/116
A
D E F
G
CB
F
rom
To
A
A
B
B
free
scan
8/3/2019 Copying Gc
36/116
A
D E F
G
CB
F
rom
To
A
A
B
B
free
scan
8/3/2019 Copying Gc
37/116
A
D E F
G
CB
F
rom
To
A
A
B
B
free
scan
8/3/2019 Copying Gc
38/116
A
D E F
G
CB
F
rom
To
A
A
B
B
free
scan
8/3/2019 Copying Gc
39/116
A
D E F
G
CB
F
rom
To
A
A
B
B
free
scan
8/3/2019 Copying Gc
40/116
A
D E F
G
CB
F
rom
To
A
A
B
B
C
C
free
scan
8/3/2019 Copying Gc
41/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
free
scan
8/3/2019 Copying Gc
42/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
free
scan
8/3/2019 Copying Gc
43/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
free
scan
8/3/2019 Copying Gc
44/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
free
scan
8/3/2019 Copying Gc
45/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
free
scan
8/3/2019 Copying Gc
46/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
D
D
scan
free
8/3/2019 Copying Gc
47/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
D
D
scan
free
8/3/2019 Copying Gc
48/116
A
D E F
G
CB
F
rom
To
A
B
B
C
CA
D
D
scan
free
8/3/2019 Copying Gc
49/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
scan
free
8/3/2019 Copying Gc
50/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
scan
free
8/3/2019 Copying Gc
51/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
scan
free
8/3/2019 Copying Gc
52/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
scan
free
8/3/2019 Copying Gc
53/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
scan
free
8/3/2019 Copying Gc
54/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
scan
free
8/3/2019 Copying Gc
55/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
scan
free
8/3/2019 Copying Gc
56/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
Fscan
free
8/3/2019 Copying Gc
57/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
Fscan
free
8/3/2019 Copying Gc
58/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
Fscan
free
8/3/2019 Copying Gc
59/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
Fscan
free
8/3/2019 Copying Gc
60/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
Fscan
free
8/3/2019 Copying Gc
61/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
Fscan
free
8/3/2019 Copying Gc
62/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
F
G
Gscan
free
8/3/2019 Copying Gc
63/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
F
G
Gscan
free
8/3/2019 Copying Gc
64/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
F
G
G
free
scan
8/3/2019 Copying Gc
65/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
F
G
G
free
scan
8/3/2019 Copying Gc
66/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
F
G
G
free
scan
8/3/2019 Copying Gc
67/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
F
G
G
free
scan
8/3/2019 Copying Gc
68/116
A
D E F
G
CB
From
To
A
B
B
C
CA
D
D
E
E
F
F
G
G
free
scan
8/3/2019 Copying Gc
69/116
6 Assumptions
Size of nodes known
Child fields known
Two logically contiguous areas for the heap
Ability to mark nodes
8/3/2019 Copying Gc
70/116
6 Assumptions
Size of nodes known
Child fields known
Two logically contiguous areas for the heap
Ability to mark nodes
8/3/2019 Copying Gc
71/116
6 Assumptions
Size of nodes known
Child fields known
Two logically contiguous areas for the heap
Ability to mark nodes
8/3/2019 Copying Gc
72/116
6 Assumptions
Size of nodes known
Child fields known
Two logically contiguous areas for the heap
Ability to mark nodes
8/3/2019 Copying Gc
73/116
6 Assumptions
Size of nodes known
Child fields known
Two logically contiguous areas for the heap
Ability to mark nodes
8/3/2019 Copying Gc
74/116
7 Properties
Constant stack required
Time depends only on no. of live nodes
Covers cycles / sharing
Heap is compacted
Stop/start collector
Nothing to do between GCs
8/3/2019 Copying Gc
75/116
7 Properties
Constant stack required
Time depends only on no. of live nodes
Covers cycles / sharing
Heap is compacted
Stop/start collector
Nothing to do between GCs
8/3/2019 Copying Gc
76/116
7 Properties
Constant stack required
Time depends only on no. of live nodes
Covers cycles / sharing
Heap is compacted
Stop/start collector
Nothing to do between GCs
8/3/2019 Copying Gc
77/116
7 Properties
Constant stack required
Time depends only on no. of live nodes
Covers cycles / sharing
Heap is compacted
Stop/start collector
Nothing to do between GCs
8/3/2019 Copying Gc
78/116
7 Properties
Constant stack required
Time depends only on no. of live nodes
Covers cycles / sharing
Heap is compacted
Stop/start collector
Nothing to do between GCs
8/3/2019 Copying Gc
79/116
7 Properties
Constant stack required
Time depends only on no. of live nodes
Covers cycles / sharing
Heap is compacted
Stop/start collector
Nothing to do between GCs
8/3/2019 Copying Gc
80/116
7 Properties
Constant stack required
Time depends only on no. of live nodes
Covers cycles / sharing
Heap is compacted
Stop/start collector
Nothing to do between GCs
8/3/2019 Copying Gc
81/116
8 Disadvantages
High Level
Copying large objects is expensive
Twice the logical memory needed
Low Level
Breadth first
decreased locality Paging issues
8/3/2019 Copying Gc
82/116
8 Disadvantages
High Level
Copying large objects is expensive
Twice the logical memory needed
Low Level
Breadth first
decreased locality Paging issues
8/3/2019 Copying Gc
83/116
8 Disadvantages
High Level
Copying large objects is expensive
Twice the logical memory needed
Low Level
Breadth first
decreased locality Paging issues
8/3/2019 Copying Gc
84/116
8 Disadvantages
High Level
Copying large objects is expensive
Twice the logical memory needed
Low Level
Breadth first decreased locality
Paging issues
8/3/2019 Copying Gc
85/116
8 Disadvantages
High Level
Copying large objects is expensive
Twice the logical memory needed
Low Level
Breadth first decreased locality
Paging issues
8/3/2019 Copying Gc
86/116
9 Variations(1)
Large Object Areas
(possibly handled by different collector)
Areas for long living objects
(only scanned, not copied)
Maintain locality by using other exploration strategies
(but then stack becomes an issue)
8/3/2019 Copying Gc
87/116
9 Variations(1)
Large Object Areas
(possibly handled by different collector) Areas for long living objects
(only scanned, not copied)
Maintain locality by using other exploration strategies
(but then stack becomes an issue)
8/3/2019 Copying Gc
88/116
9 Variations(1)
Large Object Areas
(possibly handled by different collector) Areas for long living objects
(only scanned, not copied)
Maintain locality by using other exploration strategies
(but then stack becomes an issue)
8/3/2019 Copying Gc
89/116
9 Variations(1)
Large Object Areas
(possibly handled by different collector) Areas for long living objects
(only scanned, not copied)
Maintain locality by using other exploration strategies
(but then stack becomes an issue)
8/3/2019 Copying Gc
90/116
9 Variations(1)
Large Object Areas
(possibly handled by different collector) Areas for long living objects
(only scanned, not copied)
Maintain locality by using other exploration strategies
(but then stack becomes an issue)
8/3/2019 Copying Gc
91/116
9 Variations(1)
Large Object Areas
(possibly handled by different collector) Areas for long living objects
(only scanned, not copied)
Maintain locality by using other exploration strategies
(but then stack becomes an issue)
8/3/2019 Copying Gc
92/116
9 Variations(1)
Large Object Areas
(possibly handled by different collector) Areas for long living objects
(only scanned, not copied)
Maintain locality by using other exploration strategies
(but then stack becomes an issue)
8/3/2019 Copying Gc
93/116
10 Variations(2)
Approximately depth-first copying(1)
Modification of Cheneys agorithm by Moon (1984)
Always start scanning on the last partially filled page in To-space
When that page is completed, continue with ordinary scan
As soon as an object is copied, start partial scan again
scan partial free
8/3/2019 Copying Gc
94/116
10 Variations(2)
Approximately depth-first copying(1)
Modification of Cheneys agorithm by Moon (1984)
Always start scanning on the last partially filled page in To-space
When that page is completed, continue with ordinary scan
As soon as an object is copied, start partial scan again
scan partial free
8/3/2019 Copying Gc
95/116
10 Variations(2)
Approximately depth-first copying(1)
Modification of Cheneys agorithm by Moon (1984)
Always start scanning on the last partially filled page in To-space
When that page is completed, continue with ordinary scan
As soon as an object is copied, start partial scan again
scan partial free
8/3/2019 Copying Gc
96/116
10 Variations(2)
Approximately depth-first copying(1)
Modification of Cheneys agorithm by Moon (1984)
Always start scanning on the last partially filled page in To-space
When that page is completed, continue with ordinary scan
As soon as an object is copied, start partial scan again
scan partial free
8/3/2019 Copying Gc
97/116
10 Variations(2)
Approximately depth-first copying(1)
Modification of Cheneys agorithm by Moon (1984)
Always start scanning on the last partially filled page in To-space
When that page is completed, continue with ordinary scan
As soon as an object is copied, start partial scan again
scan partial free
8/3/2019 Copying Gc
98/116
11 Variations(3)
Approximately depth-first copying(2)
Drawback: Some nodes are scanned twice
Tests indicate a 15 percent improvement of locality
. . . and a 6 percent increased GC time
8/3/2019 Copying Gc
99/116
11 Variations(3)
Approximately depth-first copying(2)
Drawback: Some nodes are scanned twice
Tests indicate a 15 percent improvement of locality
. . . and a 6 percent increased GC time
8/3/2019 Copying Gc
100/116
11 Variations(3)
Approximately depth-first copying(2)
Drawback: Some nodes are scanned twice
Tests indicate a 15 percent improvement of locality
. . . and a 6 percent increased GC time
8/3/2019 Copying Gc
101/116
11 Variations(3)
Approximately depth-first copying(2)
Drawback: Some nodes are scanned twice
Tests indicate a 15 percent improvement of locality
. . . and a 6 percent increased GC time
8/3/2019 Copying Gc
102/116
12 Increasing efficiency
Making the semi-spaces bigger decreases frequency of GC
Less frequent GC means older objects
More garbage
8/3/2019 Copying Gc
103/116
12 Increasing efficiency
Making the semi-spaces bigger decreases frequency of GC
Less frequent GC means older objects
More garbage
8/3/2019 Copying Gc
104/116
12 Increasing efficiency
Making the semi-spaces bigger decreases frequency of GC
Less frequent GC means older objects
More garbage
8/3/2019 Copying Gc
105/116
3
2
2
2
2
22x3M
B
8/3/2019 Copying Gc
106/116
3
2
2
2
2
22x3M
B
6
5
2
2
x6MB
13 W
8/3/2019 Copying Gc
107/116
13 When to use copying
Storage management dominated by allocation
(alloc. is cheap) Many small, short-lived objects
(copying small objects not much more expensive than marking)
GC delay doesnt matter (no real-time system)
13 W
8/3/2019 Copying Gc
108/116
13 When to use copying
Storage management dominated by allocation
(alloc. is cheap)
Many small, short-lived objects
(copying small objects not much more expensive than marking)
GC delay doesnt matter (no real-time system)
13 W
8/3/2019 Copying Gc
109/116
13 When to use copying
Storage management dominated by allocation
(alloc. is cheap)
Many small, short-lived objects
(copying small objects not much more expensive than marking)
GC delay doesnt matter (no real-time system)
13 W
8/3/2019 Copying Gc
110/116
13 When to use copying
Storage management dominated by allocation
(alloc. is cheap)
Many small, short-lived objects
(copying small objects not much more expensive than marking)
GC delay doesnt matter (no real-time system)
14 O
8/3/2019 Copying Gc
111/116
14 Outlook
Hybrid systems can be used
(e.g. use copying only for small objects, mark-sweep for large
objects) Copying collection can be used as a foundation for
incremental
generational
GC algorithms.
14 Outlook
8/3/2019 Copying Gc
112/116
14 Outlook
Hybrid systems can be used
(e.g. use copying only for small objects, mark-sweep for large
objects)
Copying collection can be used as a foundation for
incremental
generational
GC algorithms.
14 Outlook
8/3/2019 Copying Gc
113/116
14 Outlook
Hybrid systems can be used
(e.g. use copying only for small objects, mark-sweep for large
objects)
Copying collection can be used as a foundation for
incremental
generational
GC algorithms.
14 Outlook
8/3/2019 Copying Gc
114/116
14 Outlook
Hybrid systems can be used
(e.g. use copying only for small objects, mark-sweep for large
objects) Copying collection can be used as a foundation for
incremental
generational
GC algorithms.
14 Outlook
8/3/2019 Copying Gc
115/116
14 Outlook
Hybrid systems can be used
(e.g. use copying only for small objects, mark-sweep for large
objects) Copying collection can be used as a foundation for
incremental
generational
GC algorithms.
14 Outlook
8/3/2019 Copying Gc
116/116
14 Outlook
Hybrid systems can be used
(e.g. use copying only for small objects, mark-sweep for large
objects) Copying collection can be used as a foundation for
incremental
generational
GC algorithms.