Choosing @CompileStatic over dynamic dispatch for low‑traffic Groovy services: memory vs flexibility trade‑off
We need to lower JVM heap and per‑request CPU for a Groovy service that receives only a few requests per hour and runs in a memory‑constrained container. The default dynamic dispatch routes every call through MetaClass objects and call‑site caches, adding overhead that is not amortised by JIT on such sparse traffic. Applying @CompileStatic replaces those cal