3 ms·
If you have good generational GC (with relocation), then creating and destroying short-lived objects should be almost free? In practice, you will be re-using t
by eru 8y ago
If you have good generational GC (with relocation), then creating and destroying short-lived objects should be almost free?
In practice, you will be re-using the same areas of memory.
- kibwen 8y agoGo's GC is deliberately non-relocating, which precludes being generational. https://blog.golang.org/ismmkeynote https://blog.golang.org/ismmkeynote The repeated state in question might be benefiting from escape analysis, but I can't tell from a cursory examination.
- PavlovsCat 8y agoSure, but almost free GC is free in the same way throwing away 3 cents is almost free. Once it adds up enough to cause lost frames, anyway. Just like a straw practically weighs nothing, except when it's the straw that causes the camel to miss a frame. In this case, I also doubt it would make a difference by itself, but I haven't looked at all of the source, so I just mentioned it as something to maybe watch out for. Also, every bit of GC you can super easily avoid "buys" you room for GC that would make the code more complicated to avoid. Waste not, want not :)
- eru 8y agoOk, drop the 'almost'. GC can be as 'free' as eg stack allocation (which nobody seems to mind to much). See the comment by kibwen (https://news.ycombinator.com/item?id=18551218 https://news.ycombinator.com/item?id=18551218) for some good pointers to more concepts.