Skip to content

Strict Zero-Allocation

In high-frequency robotics (250Hz+), the #1 cause of sudden, non-deterministic jitter is the Java Garbage Collector (GC). Every time you use the new keyword inside a loop, you are creating a tiny bit of “trash” that the CPU eventually has to stop everything and clean up.

1. The Ephemeral Proxy Pattern

MARSLib enforces zero-allocation using Ephemeral Proxies. Instead of creating new Translation2d objects every loop for math, we reuse static, pre-allocated memory buffers.

Try clicking ALLOCATE OBJECT in the simulator below to see how heavy object creation “spikes” the loop time and forces the GC to halt the robot!

2. MARSLib Constraints

The marslib-audit skill strictly forbids the following patterns in “Hot Paths” (periodic loops):

  • No new: Use Inputs structs or static caches.
  • No Lambdas: Use pre-defined Runnable or Consumer fields.
  • No String Building: Use the Logger.recordOutput raw numeric overloads.



📖 Further Reading & External Resources