3 ms·
> Small ephemeral objects have the allocation costs closer to C-style stack-allocation than heap allocation in most cases (due to TLAB etc.) so, I have some co
by riku_iki 3y ago
> Small ephemeral objects have the allocation costs closer to C-style stack-allocation than heap allocation in most cases (due to TLAB etc.)
so, I have some code with one loop, which reads strings from file and does some computations, when I add single "new SomeSmallObj()" there which I would allocate on stack in C, it starts working 2 times slower. How can I debug/reason/improve this case?..
- vips7L 3y agoYou haven't provided enough details of your object allocation. It depends entirely on escape analysis and whether the JIT thinks the object escapes. If you're doing a simple non escaping allocation it shouldn't matter: var i = new SmallObject().getI(); Here's a good reading on it: https://gist.github.com/JohnTortugo/c2607821202634a6509ec3c321ebf370 https://gist.github.com/JohnTortugo/c2607821202634a6509ec3c3...