3 ms·
> How do you avoid too many allocations to happen in Java? Most of the time you don't need to, because GCs are that good, and escape analysis can avoid heap al
by pron 12y ago
> How do you avoid too many allocations to happen in Java?
Most of the time you don't need to, because GCs are that good, and escape analysis can avoid heap allocation automatically[1]. You won't get C++ latency, but you'll do better than Go. If you really need to avoid allocations for some reason, you can go off-heap for C++ performance (Java HFT applications do that for the most performance-critical things; it requires more work, but overall, less than C++).
Also, I'm not saying that Java is always the better choice (the JVM needs some time to warm up; Go's runtime is statically compiled into the native binary artifact), but in this particular case it seems to be exactly what the author was asking for, that it's really the obvious choice.
[1]: http://psy-lob-saw.blogspot.com/2014/12/the-escape-of-arraylistiterator.html http://psy-lob-saw.blogspot.com/2014/12/the-escape-of-arrayl...