line breaks

This commit is contained in:
Jidong Xiao
2023-11-25 00:12:40 -05:00
parent 495edc8e6a
commit 543aae0744

View File

@@ -78,11 +78,8 @@ root: 105
1. Split memory in half (working memory and copy memory).
2. When out of working memory, stop computation and begin garbage collection.
(a) Place scan and free pointers at the start of the copy memory.
(b) Copy the root to copy memory, incrementing free. Whenever a node is copied from working memory,
leave a forwarding address to its new location in copy memory in the left address slot of its old location.
(c) Starting at the scan pointer, process the left and right pointers of each node. Look for their locations
in working memory. If the node has already been copied (i.e., it has a forwarding address), update the
reference. Otherwise, copy the location (as before) and update the reference.
(b) Copy the root to copy memory, incrementing free. Whenever a node is copied from working memory, leave a forwarding address to its new location in copy memory in the left address slot of its old location.
(c) Starting at the scan pointer, process the left and right pointers of each node. Look for their locations in working memory. If the node has already been copied (i.e., it has a forwarding address), update the reference. Otherwise, copy the location (as before) and update the reference.
(d) Repeat until scan == free.
(e) Swap the roles of the working and copy memory.
@@ -146,9 +143,9 @@ stack:
## 25.10 Garbage Collection Comparison
- Reference Counting:
+ fast and incremental
cant handle cyclical data structures!
? requires 33% extra memory (1 integer per node)
- + fast and incremental
- cant handle cyclical data structures!
- ? requires 33% extra memory (1 integer per node)
- Stop & Copy:
requires a long pause in program execution
+ can handle cyclical data structures!
@@ -171,9 +168,13 @@ enormous beast of a programming language (but that doesnt stop people from tr
we can do? Yes, we can use Smart Pointers to gain some of the features of garbage collection.
Some examples below are modified from these nice online references:
[http://ootips.org/yonat/4dev/smart-pointers.html](http://ootips.org/yonat/4dev/smart-pointers.html)
[http://www.codeproject.com/KB/stl/boostsmartptr.aspx](http://www.codeproject.com/KB/stl/boostsmartptr.aspx)
[http://en.wikipedia.org/wiki/Smart_pointer](http://en.wikipedia.org/wiki/Smart_pointer)
[http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/smart_ptr.htm](http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/smart_ptr.htm)
[http://www.acodersjourney.com/2016/05/top-10-dumb-mistakes-avoid-c-11-smart-pointers/](http://www.acodersjourney.com/2016/05/top-10-dumb-mistakes-avoid-c-11-smart-pointers/)
## 25.12 Whats a Smart Pointer?