3 ms·
> 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
by barrkel 8y 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 8y 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 8y 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 8y agoThe updated Garbage Collection Handbook does as well.
- pjmlp 8y 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 8y 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 8y 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 8y 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.