2 ms·
Yeah, allocating / deallocating short-lived objects in Java has an almost zero cost (read about it in some article, can't remember which one). But that's not t
by bad_user 16y ago
Yeah, allocating / deallocating short-lived objects in Java has an almost zero cost (read about it in some article, can't remember which one).
But that's not the point ... stack-allocated values help with mathematics, like boolean comparisons, matrix multiplication or just plain arithmetic, because otherwise you have to box/unbox those values. Software that relies on that (graphics / animations come to my mind, but not only) ... can take a big performance hit.
And even if the GC is very efficient, you can still strangle it with many small objects, and sometimes those objects aren't deallocated fast enough. Stack allocation/deallocation is much more predictable for lots of small objects.
But I think you already addressed this point.