3 ms·
Garbage collection isn't generally something that happens periodically as it isn't needed until you get a bunch of new allocations and classically did not happe
by saurik 4y ago
Garbage collection isn't generally something that happens periodically as it isn't needed until you get a bunch of new allocations and classically did not happen on some background thread as that's both extremely difficult to pull off and requires threading support in the first place. The simpler way to think about garbage collection is you establish a heap, set a size, and when you run out of space in that heap you run a garbage collection pass during the memory allocation that failed. If you fail to free enough memory, you either kill the program or request a larger heap.
- kaba0 4y agoThis is the way it is described in the GC Handbook as well. New(): ref <- allocate() if ref = null collect() ref <- allocate() if ref = null error "Out of memory" return ref