Next Practical Step
Disable View Results Tree, set a larger HEAP for a pilot CLI run, and re-check with the Heap Estimator if you still OOM.
Fix JMeter OutOfMemoryError Java heap space: raise heap, cut threads, disable View Results Tree, trim result saving, and split injectors. Symptom and fixes.
java.lang.OutOfMemoryError: Java heap spaceOfficial best practices stress lean injectors:
| Cause | Detail |
|---|---|
| Heap too small for threads | Roughly more concurrent threads → more live objects; default heap may be too low |
| View Results Tree / heavy listeners | Keep detailed sample data in memory - debug only |
| Too many threads on one JVM | Need more engines (distributed) or lower concurrency |
| Saving too much | XML results, response data, large bodies |
| Heavy scripts | BeanShell/JavaScript on hot paths; prefer JSR223 Groovy with compile cache |
Container limit below -Xmx | cgroup kills the process (Docker/K8s) |
Switch to non-GUI for load
jmeter -n -t plan.jmx -l results.jtl -e -o report/Disable View Results Tree, View Results in Table, and other heavy listeners for the load run (best practices).
Size heap for the injector using the Heap Estimator as a starting point; set HEAP / JVM_ARGS (for example -Xms512m -Xmx2048m) per your launch scripts, then restart JMeter.
Reduce threads per engine; scale out with multiple CLI instances or remote workers rather than one huge JVM.
Prefer CSV result files and only the saveservice fields you need (dashboard requirements).
Replace expensive scripting with JSR223 + Groovy, cache compiled scripts, use vars.get("x") not embedded \${x} in cached scripts (best practices).
In Docker/K8s: set memory limits above -Xmx plus native overhead.
Re-test with a pilot; watch GC logs if problems continue.
| Resource | Use when |
|---|---|
| Heap Estimator | Starting -Xmx guess |
| Thread Calculator | Fewer threads if RPS allows |
| Distributed testing | Spread load across engines |
| Docker / Kubernetes | cgroup OOM |
| Best practices | Lean plan rules |
Often it is the JMeter injector. Confirm with injector GC/heap metrics before blaming the SUT.
GUI rendering plus listeners keep more objects alive. Official guidance: use GUI to build, CLI for load.
It depends on threads, response sizes, scripting, and listeners. Start from the Heap Estimator, then validate under a pilot run.