Hacker News new | ask | show | jobs
by chrisseaton 4068 days ago
"Reuse rather than free and reallocate is a core practice whenever you feel the need for speed"

The problem with this conventional wisdom is that it defeats other optimisations. If you free, use, and deallocate a block of memory within a compilation unit, a compiler can transparently allocate it on the stack, or even keep it in registers

If you use a free-list the objects are always escaped, and the same optimisations can't be applied to them.

This is particularly true for small temporary objects, like an intermediate vector (as in coordinates) object.