4 ms·
In taxonomy, I say we have "automatic memory management" when we have some kind of `malloc()` type device and no need to `free()` it. Garbage collection is abo
by geocar 7y ago
In taxonomy, I say we have "automatic memory management" when we have some kind of `malloc()` type device and no need to `free()` it.
Garbage collection is about visiting live objects to figure out what's alive and ignoring the dead stuff. Every theory about why GC can work (or be useful) is predicated on the idea that there is more garbage than live objects so you're touching less stuff.
If all you do is mark/sweep, you're visiting the garbage as well, so GC research has led neatly into moving collectors (which don't ever touch the garbage). That's a win, and that's why GC is worth study.
There are other kinds of "automatic memory management" though: reference counting, arena allocators (at a stretch), and object memory (I've only seen this on mainframes), and they're all worth some attention.
- barrkel 7y ago> Garbage collection is about visiting live objects to figure out what's alive and ignoring the dead stuff That's a description of tracing GC, not a definition of GC. GC is whatever technology that enables what you've called automatic memory management: a kind of illusion that there is infinite memory, from the programmer's perspective. That might involve some mix of reference counting (Python is probably the biggest example), tracing (what you seem to think is all of GC), data flow analysis (e.g. escape analysis in some Java GC / JIT integration), etc.
- seanmcdirmid 7y agoGC has always meant tracing GC while reference counting (ever since McCarthy invented it) was considered another form of automatic memory management (like using arenas, doing escape analysis, etc...). Only recently in hacker news have they become all merged into the same word, for some reason.
- chrisseaton 7y ago> Only recently in hacker news have they become all merged This is demonstrably not true. The Garbage Collection book by Jones is the key text in this area, and it covers reference counting under that term. It was published in 1996, before Hacker News existed. There is also Bacon's Unified Theory of Garbage Collection, 2004, which said the two are on a spectrum that meets in the middle. > all high-performance collectors (for example, deferred reference counting and generational collection) are in fact hybrids of tracing and reference counting
- mcguire 7y agoThe updated Garbage Collection Handbook does as well.
- pjmlp 7y agoThat reason are academic worthy books describing garbage collection algorithms, I can provide a couple of them. Lets start with the Garbage Collection Handbook, chapter 5.
- geocar 7y ago> GC is whatever technology that enables what you've called automatic memory management: a kind of illusion that there is infinite memory, from the programmer's perspective. That's definitely not what McCarthy meant by it. I understand that's probably a common view nontheless, but I can use sbrk() and the fact my computer has gobs of ram/swap, and I'm not going to call that garbage collection. I don't think this definition is useful. If you re-read what I wrote now understanding what I mean when I say "garbage collection", perhaps we can talk about strategies for providing that infinite view of memory instead.
- barrkel 7y agoActually, I think process termination is pretty useful as garbage collection. It's normally much more reliable for releasing resources, for one thing. And there's little sense in cleaning up RAM when you're just going to quit.
- geocar 7y agoThe kernel still deallocated those pages as an explicit [manual] result of a free-like call -- that just so happens to be named exit(). To seriously tell people that every C program running on unix has automatic "garbage collection" built-in seems like it would create very confusing conversations.
- deleted 7y ago[deleted]