| ▲ | kazinator 2 hours ago | |||||||||||||||||||
> Think of a service that keeps a large cache in memory, or an index built out of millions of small objects that all point at each other. Every one of those pointers has to be followed on every cycle, for as long as the process is up. That's a strange thing to assert, having acknowledged the existence of generational GC. | ||||||||||||||||||||
| ▲ | deathanatos an hour ago | parent | next [-] | |||||||||||||||||||
It occurs to me that I have never seen any description of generational GC that actually notes how that works, though. If we have two generations, young and old, we obviously can't simply "just collect in the young generation" — which I feel like is exactly what most generational GC descriptions say. If we only traced young objects, we could very well miss an old object pointing at a young one, collect the younger object, and now we've got a dangling pointer. So there must be some book-keeping to avoid tracing everything (or what'd be the point of generations), but I have no idea of what that book-keeping is, or its cost. > Show me your code and conceal your data structures, and I shall continue to be mystified. Show me your data structures, and I won't usually need your code; it'll be obvious. | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | Someone 2 hours ago | parent | prev [-] | |||||||||||||||||||
Similarly, the statement > Reference counting also has its own running cost, paid on every copy of a pointer you make and every time you drop one. isn’t 100% true. It’s not necessarily on every copy or drop. Compilers can (and do) elide reference count updates if they can proof they aren’t needed, and can even skip allocating room for reference counts if they can proof it isn’t needed (example: a local object that doesn’t escape its scope) I also find it a miss that the article doesn’t discuss memory usage. A garbage-collected program needs more memory to match the performance of the equivalent manually managed language. https://dl.acm.org/doi/10.1145/1094811.1094836 says you need to give it 5 times the memory, but that’s from 2005 and likely outdated. | ||||||||||||||||||||
| ||||||||||||||||||||