4 ms·
I'm just as confused as you are about most implementations of garbage collection. There's one that feels like it works, though: Erlang's. Erlang doesn't do any
by derefr 11y ago
I'm just as confused as you are about most implementations of garbage collection. There's one that feels like it works, though: Erlang's.
Erlang doesn't do anything different in its GCing algorithms or anything; it just gives each (really tiny) process its own heap, so there's lots of heaps, which can each be GCed at some opportune time when that particular (tiny) process isn't scheduled. It's stop-the-world GC, but with high-granularity worlds.
This seems to suggest, to me, that the "problem" of GC is not in its implementation algorithm. Generational, concurrent, real-time, whatever other clever properties: not important. A GC pass is problematic in proportion to the size of the heap. So, make smaller heaps. The easiest way is smaller processes.
- dilap 11y agoThis works for erlang 'cuz it's functional. Not gunna work for something like Go. Something like ARC would work for Go though (right?), & I agree it's a really nice approach, and I don't really get why it's not more widely used.
- vezzy-fnord 11y agoIt works for Erlang because of its process model. I don't think it has anything to do with it being functional.
- dilap 11y agoYup, you're right. I just meant that to have a program composed of many processes that can be stopped & collected independently, those processes have to communicate 'functionally', i.e., without shared mutable memory. (So this isn't a viable approach for languages like Go where all the goroutines share memory.)
- masklinn 11y ago> So this isn't a viable approach for languages like Go where all the goroutines share memory. Something Go has been criticised for since it was originally unveiled back in 2009.
- chaotic-good 11y agoIn erlang old data structures can't reference new data. This simplifies GC a lot.
- vezzy-fnord 11y agoImmutability is orthogonal to FP as a whole.
- fauigerzigerk 11y agoIf that works or not depends on the application. It doesn't work for large in-memory datasets that are acessed by multiple processes.
- the8472 11y ago> Generational, concurrent, real-time, whatever other clever properties: not important. Those properties cut down the pause time in relation to the heap size. The more sophisticated your GC the larger your heap can be for the same pause time. Until you reach the point where you have a fully-concurrent, pause-free GC. Of course pause-free GCs aren't free lunch either. They incur increased memory traffic, require more CPU cycles per megabyte collected, require more headroom (i.e. larger memory footprint) to maintain their properties...