I've heard of Java programs with strict latency requirements where "new" instructions are never -or very rarely- used (because no new=>no objects->no GC=>improved latency)... instead all business logic is handled using primitives.
I couldnt find references to this technique online though... any link to a webpage discussing this technique or snippets of code would be much appreciated.
Update (March 2012): While there is no public announcement available, it appears Oracle has shut down their JavaRTS group.
The two topics you should look at are the Real-Time Specification for Java (JSR-1, JSR-282) and the Safety-Critical Specification for Java (JSR-302), (aonix page). RTSJ provides the resources for doing the type of careful memory management you are talking about in your question, though most of the users of RTSJ probably tolerate greater jitter than an "all-primitives" approach would (and, for that tolerance, they get the benefits of GC by using an RTGC). For some examples of the kinds of limited allocation (limiting when/where/how many times you can use new
) search for "rtsj scoped memory rules", and here's an example academic paper on the topic. You should also look at "eventrons" as an example of trying to solve these high-frequency, low-latency constraints in Java in a (relatively) clean way.
For a specific new story on the use of JavaRTS in trading contexts, see here. For some instructions on how to get the most deterministic behavior out of JavaRTS in particular, see here.
Safety-Critical users are more likely to have these sorts of constraints, and SC-Java is (expected to be) partially a downscoped version of RTSJ. You can see some examples of what the expert group is looking at in Doug Locke's 2007 status slides from JTRES.
Several folks produce JVMs intended for use in this environment. Aonix/Atego's PERC; aicas' JamaicaVM; Apogee's Aphelion. The Sun/Oracle JavaRTS is targeted more towards larger applications that can tolerate (and benefit from) less stringent constraints.
While the "all-primitives" approach you cite is an extreme form of this type of programming, you are most likely to find resources around this topic at one of the above references.
For the "business logic in primitives?" naysayers above me, note that substantial amounts of IRS tax business logic is implemented in IBM assembler, and a number of "enterprise" layers like Java are being looked at to wrap (not replace!) that logic. Put that in your pipe and smoke it.
I can't cite any specifics here, but there are a number of defense applications using Java (usually a flavor of RTSJ) that have very tight constraints on memory allocation, and much of the code is statically-allocated, primitive focused. Signal processing, etc... I did a search for open source materials on systems I'm aware of, and these documents (see especially the references sections) point the way to some specific examples of these applications.
I have worked on a number of such systems. You will need to worry about creating objects if you need sub millisecond latencies. It is possible to write an application which doesn't GC all day, just to avoid any GC delays.
However, 99%+ of applications don't need this extreme.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With