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

Manual control over when GC runs #169

Open
FeldrinH opened this issue Jul 4, 2023 · 3 comments
Open

Manual control over when GC runs #169

FeldrinH opened this issue Jul 4, 2023 · 3 comments

Comments

@FeldrinH
Copy link

FeldrinH commented Jul 4, 2023

Currently it seems that GC can trigger a collection any time a new Gc is allocated. I would like to have manual control over when collection can happen. (I mean I want to prevent automatic collections during allocation from happening and instead manually call a function that checks the threshold and collects if there is too much allocated memory.)

@FeldrinH FeldrinH changed the title Better control over when GC runs Manual control over when GC runs Jul 4, 2023
@Manishearth
Copy link
Owner

I think this could be done behind a cfg/feature

@stephanemagnenat
Copy link

stephanemagnenat commented May 2, 2024

Yes that would be nice to have. For example in a scripting language used in a game, one would like to run the garbage collection in between frames (e.g., after the frame has been rendered and sent to the display).
How big of a change would that feature be?

@Manishearth
Copy link
Owner

I don't think it would be that big. We already have a force_collect() function exposed. We can expose a second maybe_collect() that applies the threshold, and then have a way to disable the one place that collection is called automatically.

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

3 participants