20,741
edits
m (→Objective) |
m (→Mark/Sweep) |
||
| Line 35: | Line 35: | ||
The mark-and-sweep algorithm consists of two phases: In the first phase, it finds and marks all accessible objects. The first phase is called the mark phase. In the second phase, the garbage collection algorithm scans through the heap and reclaims all the unmarked objects. The second phase is called the sweep phase. | The mark-and-sweep algorithm consists of two phases: In the first phase, it finds and marks all accessible objects. The first phase is called the mark phase. In the second phase, the garbage collection algorithm scans through the heap and reclaims all the unmarked objects. The second phase is called the sweep phase. | ||
The mark/sweep algorithm can also be easily expressed in Nasal tself: | The mark/sweep algorithm can also be easily expressed using pseudo code, i.e. in Nasal tself: | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
| Line 75: | Line 75: | ||
Nasal's implementation of sweep() ( called reap() ) works such that it is always executed for a handful of different type-specific memory pools. In addition, it also makes sure to allocate new memory if required. | Nasal's implementation of sweep() ( called reap() ) works such that it is always executed for a handful of different type-specific memory pools. In addition, it also makes sure to allocate new memory if required. | ||
= Pool storage = | = Pool storage = | ||