In Apache JMeter's bin/jmeter, what is VERBOSE_GC and what must you do before it produces anything?
answer
- A slot with no shipped default
- Two candidates, both switched off
- Java 17 unified logging syntax
- Process id and timestamp in the filename
basics
~10 sVERBOSE_GC is a slot the launcher expands into the JVM options between HEAP and GC_ALGO. Apache ships it unset, with two commented-out -Xlog:gc candidates, so you must uncomment one or export your own.
solid answer
~40 sUnlike `HEAP` and `GC_ALGO`, Apache JMeter 6.0.0 gives `VERBOSE_GC` no default. `bin/jmeter` only ever reads `$VERBOSE_GC` when it assembles `ARGS`, and the two assignments above that point are both commented out: a comprehensive `-Xlog:gc,gc+heap,gc+regions,gc+refine,gc+phases:gc_jmeter_%p_%t.log:time,level,tags:filecount=5,filesize=50M` and a minimal `-Xlog:gc:gc_jmeter_%p.log:time` described as "Minimal GC logging for production". A stock injector therefore writes no GC log at all, however large you have made its heap. You enable it either by uncommenting one line or — better — by exporting `VERBOSE_GC` from `bin/setenv.sh`, since the script never assigns the variable and an exported value flows straight through. `bin/jmeter.bat` carries the same pair with doubled percent signs.
code
bash · 9 lines# bin/jmeter ships both of these commented out:
# VERBOSE_GC="-Xlog:gc,gc+heap,gc+regions,gc+refine,gc+phases:gc_jmeter_%p_%t.log:time,level,tags:filecount=5,filesize=50M"
# VERBOSE_GC="-Xlog:gc:gc_jmeter_%p.log:time"
# Preferred: enable it from bin/setenv.sh, leaving the launcher untouched.
export VERBOSE_GC="-Xlog:gc:gc_jmeter_%p.log:time"
# It is expanded here, between HEAP and GC_ALGO:
# ARGS="$JAVA_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS ..."go deeper
Recall that GC logging is off in a stock JMeter install and that the switch is an environment variable in the launcher rather than a property file setting.
Explain that VERBOSE_GC has no shipped default, that it is expanded between HEAP and GC_ALGO, and that exporting it works because the script only reads the variable and never assigns it.
Show judgment about which of the two shipped strings you would enable on a live injector, and note the rotation the comprehensive one carries so the log cannot fill the generator's disk.
Decide whether GC logging is standing configuration or an investigation tool on your generators, and make that choice reproducible in setenv.sh rather than in a hand-edited launcher.
## A slot the launcher leaves empty `VERBOSE_GC` is one of the variables `bin/jmeter` expands into the JVM command line: ```sh ARGS="$JAVA_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER" ``` Unlike `HEAP` and `GC_ALGO`, Apache JMeter 6.0.0 never assigns it a default. The script contains only two commented-out candidates: ```sh # VERBOSE_GC="-Xlog:gc,gc+heap,gc+regions,gc+refine,gc+phases:gc_jmeter_%p_%t.log:time,level,tags:filecount=5,filesize=50M" # VERBOSE_GC="-Xlog:gc:gc_jmeter_%p.log:time" ``` So the slot expands to nothing on a stock install: **an injector you have raised past its shipped gigabyte still writes no GC log until you enable one.** ## Two ways to turn it on 1. **Uncomment one of the lines** in `bin/jmeter`. Simple, but it edits the launcher — the file the script's own header tells you to leave alone. 2. **Export it**, from `bin/setenv.sh` or from the calling shell. Because the script only ever *reads* `$VERBOSE_GC` and never assigns it, an exported value flows straight through into `ARGS`, which keeps your customisation out of the shipped file. Windows carries the same pair in `bin/jmeter.bat`, written `rem set VERBOSE_GC=...` and with the percent signs doubled (`%%p`, `%%t`) as batch files require. ## Reading the shipped flag string The comprehensive candidate is Java's unified logging, and each part is doing something: - `gc,gc+heap,gc+regions,gc+refine,gc+phases` — the tag selection. - `gc_jmeter_%p_%t.log` — the output file, with `%p` the process id and `%t` the start timestamp, so parallel or repeated runs on one generator do not collide. - `time,level,tags` — the decorators stamped on each line. - `filecount=5,filesize=50M` — rotation, capping the log at five files of fifty megabytes. The alternative line, described in the script as "Minimal GC logging for production", keeps only the `gc` tag and the `time` decorator. ## Why it ships off The comment above the pair reads "Legacy GC verbose options removed (Java 8/9 support discontinued)": the older `-XX:+PrintGCDetails` style flags are gone with JMeter 6's Java 17 minimum, and what remains is `-Xlog`. Leaving it commented out keeps a stock run from writing a rotating log nobody asked for, while keeping a ready-made flag string one edit away. Two other assignments in the same neighbourhood ship the same way — `RUN_IN_DOCKER="-XX:+UseContainerSupport"` is commented out because container memory detection is automatic on Java 17+, and the script suggests `-XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem` in a comment beside `GC_ALGO` without setting them. ## What it does not replace `VERBOSE_GC` only turns logging on. It changes no collector setting — that is `GC_ALGO`, which ships as `-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20`. It is also not the heap-dump switch: `bin/jmeter` sets `DUMP="-XX:+HeapDumpOnOutOfMemoryError"` unconditionally, so a dump on exhaustion is already armed whether or not you ever touch `VERBOSE_GC`. Interpreting the pause output the flag produces is a separate skill from arming it.
- Why can you export VERBOSE_GC without editing bin/jmeter at all?Because the script never assigns it. `HEAP` and `GC_ALGO` use the `: "${VAR:=default}"` form, but `VERBOSE_GC` appears only as `$VERBOSE_GC` inside the `ARGS` string. An exported value is therefore visible to the script and expands in place, which is why `bin/setenv.sh` is the tidy way to switch it on.
- Does enabling VERBOSE_GC change how the injector collects garbage?No. It only adds `-Xlog` output. The collector and its settings come from `GC_ALGO`, which ships as `-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20`. A separate switch, `DUMP`, is set unconditionally to `-XX:+HeapDumpOnOutOfMemoryError`, so a dump on exhaustion is already armed whether or not you enable GC logging.
saying these in an interview costs you the question
- Believes JMeter writes a GC log by default
- Thinks VERBOSE_GC selects the garbage collector
- Confuses it with the always-on OOM heap dump
- Misses that the filename carries %p and %t
- Expects a jmeter.properties key to enable it