From b03cb723882fcbe25cff5742b6ce93440357dc0c Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sun, 27 Nov 2022 11:10:23 -0500 Subject: [PATCH] Revised sweep section --- docs/Garbage-Collector-Revised-2022.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/Garbage-Collector-Revised-2022.md b/docs/Garbage-Collector-Revised-2022.md index 63e7cbad..c0c5ce96 100644 --- a/docs/Garbage-Collector-Revised-2022.md +++ b/docs/Garbage-Collector-Revised-2022.md @@ -228,12 +228,12 @@ The collector finds all live objects using a breadth-first search and marks them Initial object graph ### Sweep -The collector scans the heap and frees memory used by all white objects: +This function is included here for completeness but is actually performed much later due to [lazy sweeping](#lazy-sweeping). + +When the time comes to reclaim memory a mutator scans a heap page and frees memory used by any of the white objects: Initial object graph -If the heap is still low on memory at this point the heap will be increased in size. Also, to ensure a complete collection, data for any terminated threads is not freed until now. - ### Resting The collector cycle is complete and it rests until it is triggered again. @@ -304,6 +304,8 @@ In addition when a mutator transitions to async it will: Cyclone's mutators cooperate after each minor GC, for two reasons. Minor GC's are frequent and immediately afterwards all of the mutator's live objects can be marked because they are on the heap. +Finally, at the end of a collection cycle the main thread must clean up heap data for any terminated threads. + ### Mark Gray Mutators call this function to add an object to their mark buffer.