Coding for Zero Garbage
Overview
Talon's pooling, messaging and state types are designed to support zero garbage operation once the system reaches steady state. Relying on JVM garbage collection can introduce unpredictable pauses, particularly when applications have large heap sizes. Zero garbage programming eliminates allocation that triggers GC pauses enabling applications to operate at consistently low latencies.
This section discusses techniques and best practices for achieving zero garbage operation with Talon microservices.
Weighing Alternatives
Achieving zero garbage operation is an advanced technique. The cost of engineering software for zero garbage operation can have trade offs in the complexity of the code as the user must be conscious about re-using application objects. In some cases tuning the JVM or using a GC-optimized JVM may be a more cost effective approach. For example, using Azul's Zing JVM provides near pauseless GC with significantly lower development complexity than zero-garbage techniques.
Before pursuing zero garbage techniques, consider:
Performance Requirements: Is sub-millisecond latency critical? Standard GC tuning may suffice for many use cases
Development Complexity: Zero garbage programming requires careful lifecycle management and reference counting
Maintenance Burden: More complex code is harder to maintain and evolve
JVM Alternatives: Modern low-latency JVMs like Zing may provide sufficient GC pause reduction
Zero Garbage Techniques
Talon provides several facilities for achieving zero garbage operation:
XStrings - Zero garbage string handling with pooled, mutable strings
Embedded Entities - Lifecycle-managed objects for complex message composition
Array Accessors - XIterator pattern for allocation-free array iteration
Application Object Pooling - Creating custom pooled objects with reference counting
Tuning Pools - Configuration and optimization of pool parameters
See Also
Programming Fundamentals - Core programming rules including messaging and threading constraints
Handling Messages - Message handler best practices
Configuring Adaptive Batching - Transaction batching for throughput optimization
Last updated

