TL;DR: OCaml 5 could more than double Semgrep's interfile analysis memory use until major garbage collector settings were tuned dynamically, according to Semgrep. Runtime memory governance now has to track workload size and repository shape, or RSS can rise faster than static GC assumptions allow.
Editorial analysis by NHI Mgmt Group, based on content published by Semgrep: “Upgrading Semgrep from OCaml 4 to OCaml 5”.
Key questions
Q: How should teams choose GC settings when workload sizes vary widely?
A: Teams should tune garbage collection against representative workload classes instead of one median case.
Q: What are the signs that a memory regression is caused by GC behaviour?
A: A GC-driven regression usually shows up as higher RSS, slower reclamation of dead values, and a gap between live allocation traces and the process footprint the operating system sees.
Q: Why do runtime upgrades sometimes increase memory use on the same workload?
A: Runtime upgrades can change garbage collection and allocation behaviour even when the application code does not change.
Practitioner guidance
- Profile live memory and process RSS together Use both allocation tracing and operating-system memory polling when validating runtime changes so you can separate delayed collection from true footprint growth.
- Test runtime upgrades against representative workload sizes Benchmark small, medium, and large repositories separately, because the GC setting that works for one scan shape may degrade either latency or memory at another scale.
- Treat GC parameters as production controls Document which runtime parameters affect availability, assign ownership for them, and review them after language or runtime upgrades just as you would other capacity-sensitive settings.
Bottom line: OCaml 5 introduced a memory-behaviour change that exposed the limits of static GC assumptions in a real analysis workload.
Glossary terms: Garbage Collector Tuning, Resident Set Size, Disk Fragmentation, Dynamic Runtime Control
Explore further
View Full Forum → | NHI Foundation Course → | Our Services → | Read the full analysis →
Runtime memory governance is now part of security tooling reliability. When analysis engines, scanners, or policy services move to newer runtimes, the main failure mode is often not functional breakage but resource instability. That instability can degrade the controls downstream teams rely on, especially when a tool must finish work under bounded memory. The practitioner takeaway is to treat runtime tuning as a control-plane decision, not a purely engineering detail.
A question worth separating out:
Q: When should organisations use adaptive runtime controls instead of static defaults?
A: Use adaptive controls when workload shape, repository size, or traffic patterns vary enough that one default produces contradictory outcomes. In that situation, a single value forces a tradeoff between speed and memory that may be acceptable for one job and harmful for another. Adaptive tuning keeps the control aligned to current runtime conditions instead of stale assumptions.
👉 Read our full editorial: Dynamic garbage collection tuning for memory-heavy OCaml workloads