Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garbage Collector does not need .unmark() #60

Open
BenGoldberg1 opened this issue Feb 10, 2024 · 1 comment
Open

Garbage Collector does not need .unmark() #60

BenGoldberg1 opened this issue Feb 10, 2024 · 1 comment

Comments

@BenGoldberg1
Copy link

This suggestion uses a little extra memory to save a little bit of time.

Change the type of mark from a boolean to an integer, and add an integer gc_count which keeps track of how many times garbage collection has happened.

When marking objects as being accessible, assign the value of gc_count to the 'mark' of every reachable object.

Objects whose mark is not equal to gc_count can be freed.

For objects being kept, the mark can be left as is.

If you come across an object whose mark is not gc_cur or gc_cur-1, panic.

If you think corruption is inconceivable, leave mark as a bool, but on alternate GCs, cycle between assigning true and false to it

@CeleritasCelery
Copy link
Owner

Hi @BenGoldberg1 , That is a great idea! You could even just use a u8 and keep the mark bit the same size. That would save us from needing to reset the the mark bits each time we are done sweeping. I am in the process of rewriting the garbage collector to be a generational copying version, so this is definitely something I will keep in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants