Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chapter16_bonus_projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h2 id='garbage_collection'>Garbage Collection</h2> <hr/>
<p><small>Garbage Collection &bull; Pick up that can.</small></p>
</div>

<p>If we store pointers to values, rather than copies, we need to ensure that the data pointed to is not delete before some other value tries to make use of it. We want to deleted it when there are no longer any references to it. One method to do this, called <em>Mark and Sweep</em>, is to monitor those values that are in the environment, as well as every value that has been allocated. When a variable is put into the environment it, and everything it references, is <em>marked</em>. Then, when we wish to free memory, we can then iterate over every allocation, and delete any that are not marked.</p>
<p>If we store pointers to values, rather than copies, we need to ensure that the data pointed to is not deleted before some other value tries to make use of it. We want to delete it when there are no longer any references to it. One method to do this, called <em>Mark and Sweep</em>, is to monitor those values that are in the environment, as well as every value that has been allocated. When a variable is put into the environment it, and everything it references, is <em>marked</em>. Then, when we wish to free memory, we can then iterate over every allocation, and delete any that are not marked.</p>

<p>This is called <em>Garbage Collection</em> and is an integral part to many programming languages. As with pool allocation, implementing a <em>Garbage Collector</em> does not need to be complicated, but it does need to be done carefully, in particularly if you wish to make it efficient. Implementing this would be essential to making this language practical for working with large amounts of data. A particularly good tutorial on implementing a garbage collector in C can be found <a href="http://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/">here</a>.</p>

Expand Down