Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What is JVM ergonomics? List decisions it makes when you start a JVM with no tuning flags.

JVM ergonomics is the JVM choosing its own defaults from the hardware or container limits it detects when it starts. With no tuning flags, it chooses the garbage collector (G1 on a server-class machine, Serial on a small one), sets the initial and maximum heap as fractions of the available memory, sets the number of GC threads, JIT compiler threads and the code cache size, and derives other values from the CPU count. Because every one of these depends on CPUs and memory, the same image can behave quite differently in a small pod and a large one.

Why this question is asked

Most Java services start with very few JVM flags, so ergonomics decides much of how they run. Understanding it explains common surprises: why a service uses Serial GC in one environment and G1 in another, why the heap is smaller than expected, or why a test environment does not represent production. Interviewers ask about it because it is the starting point for any tuning decision: we need to know what the JVM already picked before we change anything. In this answer, we will define ergonomics, walk through the collector choice, the heap defaults, the thread counts and the code cache, and then see how to inspect all of it.

1What Ergonomics Means

Ergonomics is the name for the logic that runs at JVM startup and turns the detected environment into default settings. First the JVM detects how many CPUs it may use and how much memory it has, reading container limits through cgroups when it runs in a container. Then it applies a set of rules to pick values for options we did not set ourselves. Anything we set explicitly on the command line wins over ergonomics.

The idea is that a JVM should run reasonably well without tuning, on a laptop as well as on a 64-core server. The catch is that the same rules give different answers on different machines, so we need to know them.

2Decision 1: The Garbage Collector

The JVM first decides whether it is running on a server-class machine. On current JDKs that means at least two CPUs and at least about 2 GB of memory (the check uses 1792 MB to allow for rounding). On a server-class machine it chooses G1, the default collector since JDK 9, which balances throughput and pause times. Otherwise it chooses Serial, a simple collector that uses one thread and stops the application while it works. Serial is efficient for tiny heaps and single CPUs, but its pauses grow with the heap.

Step throughHow ergonomics picks the collector
  1. Collector set on the command line?
    YesUse itNoCheck the machine
  2. At least 2 CPUs?
    YesCheck memoryNoSerial GC
  3. At least about 1792 MB of memory?
    YesG1 GCNoSerial GC

3 steps in order. Play them, or step through them one at a time.

3Decision 2: Initial and Maximum Heap

Without -Xms and -Xmx, the heap sizes are fractions of the available memory. The maximum heap is MaxRAMPercentage, 25 percent by default. The initial heap is InitialRAMPercentage, 1.5625 percent, which is one sixty-fourth. For very small memory sizes, MinRAMPercentage, 50 percent, is used for the maximum instead, so tiny containers do not end up with a uselessly small heap.

Java
// a container with 4 GiB and 2 CPUs, no flags
Runtime rt = Runtime.getRuntime();
System.out.println(rt.maxMemory() / (1 << 20)); // about 1024 (MB): 25 percent of 4 GiB
System.out.println(rt.totalMemory() / (1 << 20)); // about 64 (MB): the initial heap, 4 GiB / 64
System.out.println(rt.availableProcessors()); // 2

Notice that the heap starts at 64 MB and grows as needed. Each growth step costs some work, and for a server that owns its container we often prefer to set both values explicitly. Also notice that only a quarter of the container is used for the heap by default, which is usually too little for a dedicated service.

4Decision 3: Threads and the Code Cache

The CPU count drives several thread counts. ParallelGCThreads, the threads that work during a stop-the-world GC phase, equals the CPU count up to 8, then grows more slowly, by five eighths of each additional CPU, so 64 CPUs give 43. ConcGCThreads, the threads G1 uses for work that runs alongside the application, is roughly a quarter of that. CICompilerCount, the number of JIT compiler threads, grows with the logarithm of the CPU count: 2 for 2 CPUs, 3 for 4 CPUs and 18 for 64 CPUs on recent 64-bit JDKs. Outside the JVM itself, the ForkJoinPool common pool uses the CPU count minus one.

The code cache is where the JIT stores compiled machine code. With tiered compilation, which is the default, its reserved size is 240 MB, split into segments for different kinds of code. Ergonomics also sets other values such as the G1 region size, which is chosen from the heap size so that the heap has about 2048 regions, between 1 MB and 32 MB each (larger on newer JDKs; check your version).

Ergonomic defaults on two pod sizes
Value1 CPU, 1.5 GiB4 CPU, 8 GiB
CollectorSerialG1
Max heap (25 percent)about 384 MBabout 2 GB
Initial heap (1/64)about 24 MBabout 128 MB
ParallelGCThreads14
CICompilerCount2 (check your version)3
Common pool parallelism13
Same image, same flags: different collector, heap and thread counts.

5Seeing the Decisions and Why They Matter

We can print every value ergonomics chose. PrintFlagsFinal marks them with {ergonomic} in the origin column, and -Xlog:gc+init on recent JDKs prints a short summary of the collector setup at startup.

Properties
# in a production-shaped pod: 4 CPUs, 8 GiB
java -XX:+PrintFlagsFinal -version | grep ergonomic
# uint CICompilerCount = 3 {product} {ergonomic}
# size_t MaxHeapSize = 2147483648 {product} {ergonomic}
# bool UseG1GC = true {product} {ergonomic}
java -Xlog:gc+init -version
# [0.005s][info][gc,init] Version: 25 ...
# [0.005s][info][gc,init] CPUs: 4 total, 4 available
# [0.005s][info][gc,init] Heap Max Capacity: 2G

The practical consequence is that one container image is not one behaviour. A team that tests in a 1 CPU staging pod gets Serial GC and one GC thread, while production with 4 CPUs gets G1 and four. Their GC logs, pause times and throughput will differ, and conclusions from one may not hold in the other. That is why we make the important choices, such as the collector and the heap percentage, explicit, and why we test performance on pods shaped like production.

6Follow-up questions

Can I turn ergonomics off?

Not as a whole, but every value it chooses can be set explicitly, and an explicit option always wins. In practice we set the few values that matter, such as the collector and heap percentage, and let ergonomics handle the rest.

Does ergonomics react to load while the JVM runs?

Mostly it decides at startup. Some collectors adapt during the run, for example G1 resizes the young generation to meet its pause goal and the heap can grow between the initial and maximum sizes, but the collector choice, maximum heap and thread counts are fixed when the JVM starts.

Why is the default heap only 25 percent?

The default was chosen for machines shared by many processes, where taking all memory would be rude. In a container that runs one service, it is usually too low, so we set MaxRAMPercentage, typically to between 60 and 80 percent.

7Conclusion

In this answer, we saw that ergonomics is the JVM choosing defaults from detected CPUs and memory. It picks G1 on server-class machines with at least two CPUs and about 2 GB, Serial otherwise; sets the maximum heap to 25 percent and the initial heap to one sixty-fourth of memory; derives GC threads, JIT compiler threads and the common pool from the CPU count; and sizes the code cache. Because all of this depends on the environment, the same image behaves differently in different pods, so we inspect the choices and make the important ones explicit.

What to say in the interviewAbout 90 seconds aloud

Open with

Ergonomics is the JVM picking its own defaults from what it detects at startup: the number of CPUs and the amount of memory, which in a container means the cgroup limits.

Then, if they want more

Anything I set explicitly overrides it. With no flags, the first decision is the collector. If the machine is server class, at least two CPUs and roughly two gigabytes, it picks G1, otherwise Serial.

Then the heap: the maximum is MaxRAMPercentage, 25 percent of memory, and the initial heap is one sixty-fourth, so in a 4 gigabyte pod I get a 1 gigabyte max heap that starts at 64 megabytes.

Then thread counts: ParallelGCThreads equals the CPU count up to eight and grows more slowly after that, concurrent GC threads are about a quarter of that, and JIT compiler threads grow with the log of the CPU count. It also sizes the code cache, 240 megabytes reserved with tiered compilation, and things like the G1 region size.

The common pool, outside the JVM core, uses CPUs minus one. The important consequence is that one image doesn't mean one behaviour: a 1 CPU staging pod runs Serial with one GC thread, while 4 CPU production runs G1.

I check the choices with PrintFlagsFinal, where they're marked ergonomic, and make the important ones explicit, mainly the collector and heap percentage.

About this answer

Last updated
12 November 2026
Versions it names
Java 9
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is JVM ergonomics? List decisions it makes when you start a JVM with no tuning flags.": https://scrivio-interview-library.netlify.app/java/jvm-tuning/6e4cdd6882/