Hacker News new | past | comments | ask | show | jobs | submit login

> 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?..




You 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/c2607821202634a6509ec3c3...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: