Hacker News new | ask | show | jobs
by Archit3ch 1118 days ago
Follow-up question: is there a way to "freeze" the GC? As in, I've done all my allocations, now I want to run a main loop uninterrupted, and force clean up inside at_exit().
3 comments

If you're not allocating, the gc won't run anyway. If you made a mistake and are allocating where you don't want to be, a gc pause might be preferable to a crash.
Try setting or binding SB-KERNEL:*GC-INHIBIT* to true.
That's a recipe for disaster. Never do that.
Damn, I searched the sources on GitHub for WITHOUT-GC but found nothing; I should have searched for SB-SYS:WITHOUT-GCING which is the actual user-facing interface. Thanks for the correction.
SYS:WITHOUT-GCING is better but is still fraught with danger (that's why I didn't mention it).
I think you'll want without-interrupts for that: https://sbcl.org/sbcl-internals/The-deferral-mechanism.html
That's not related to garbage collection.