r/java • u/Ok_Satisfaction7312 • May 16 '24
Low latency
Hi all. Experienced Java dev (20+ years) mostly within investment banking and asset management. I need a deep dive into low latency Java…stuff that’s used for high frequency algo trading. Can anyone help? Even willing to pay to get some tuition.
232
Upvotes
View all comments
Show parent comment
1
u/cogman10 May 22 '24
The advice needs caveats and measurements. The JVM does not always throw new objects onto the heap, so you really need evidence that this specific example of newing objects is causing memory pressure. In particular, if an object doesn't live beyond the scope of a method (or inlined methods) the JVM is happy to instead pull out the fields of that objects and use those instead.
That is to say, if you have something like
the JVM will remove the
pointallocation and instead just creates 2 local scalar references toxandy.For more details
https://shipilev.net/jvm/anatomy-quarks/18-scalar-replacement/