5 ms·
> since allocating them is usually just a pointer bump, they can be as cheap as stack objects. I don't think that's quite true. Even with a copying/moving GC,
by snek_case 4y ago
> since allocating them is usually just a pointer bump, they can be as cheap as stack objects.
I don't think that's quite true. Even with a copying/moving GC, you still need to traverse all the live objects and then copy all of them. Asymptotically as cheap as stack objects maybe, but in reality the overhead is greater. GCs also have some amount of overhead due to all the synchronization they need to do.
- layer8 4y ago> you still need to traverse all the live objects and then copy all of them. The live objects traversed are generally not short-lived objects, because those aren’t live anymore! Meaning, short-lived objects typically aren’t traversed and therefore don’t contribute to the GC cost like longer-lived objects do.