Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

JVM memory management moved from many separately sized areas (a fixed PermGen, fixed young and old sizes) toward adaptive, region-based and self-sizing designs. Explain why, and how this trend should shape your company's memory configuration standards.

Fixed, separately sized areas needed an expert to tune them and broke as soon as the workload changed, which is why HotSpot moved to a pause-goal driven G1, an on-demand metaspace, container awareness and collectors like ZGC that size much of their own work. Our standards should follow the same direction: set the total memory budget, meaning the container limit and the heap as a percentage of it, keep a few guard limits on leak-prone areas, and otherwise let the JVM size its internal areas, reviewing the standard on each LTS release.

Why this question is asked

Many company runbooks still carry JVM flags copied from a tuning guide written for Java 6: fixed young generation sizes, survivor ratios, PermGen sizes. They often make things worse on a modern JVM. A leader who sets memory standards for many teams needs to understand why the platform changed direction, so that the standard works with the JVM instead of fighting it. Interviewers ask this to see whether we can turn platform history into policy. In this answer, we will look at what went wrong with fixed areas, how the modern JVM adapts on its own, what containers changed, and then what a good company standard contains and how it should evolve.

1The Problem With Fixed Memory Areas

Older HotSpot setups divided memory into areas with sizes we chose up front: a permanent generation, PermGen, for class metadata, a young generation of a fixed size, survivor spaces with a fixed ratio, and an old generation for the rest. Each number was a guess about the workload.

Guesses go stale. An application that added a few libraries or reloaded its web application a few times ran out of PermGen and died with OutOfMemoryError: PermGen space, even though the heap had plenty of room. A young generation sized for last year's traffic became too small after a feature launch, so survivors overflowed and objects were promoted prematurely into the old generation, which then needed long full GCs. Every service needed someone who understood all these knobs, and every change in traffic or code could invalidate their work.

2How the Modern JVM Adapts Instead

The platform answered by replacing sizes with goals and on-demand growth. G1, the default collector since JDK 9, takes a pause-time goal (MaxGCPauseMillis, 200 ms by default) and resizes the young generation after every collection to meet it. It decides adaptively when to start concurrent marking, too. Metaspace, which replaced PermGen in JDK 8, lives in native memory and grows as classes are loaded; since JDK 16 it also returns unused memory to the operating system more promptly. ZGC goes further: we give it a maximum heap and it decides how many threads to use and when to collect, with pauses that do not grow with heap size.

Notice the catch: these mechanisms only work if we let them. Setting -Xmn or NewRatio with G1 fixes the young generation size and switches off the pause-goal adaptation. Many old flags that people keep in their scripts quietly disable the very feature that would have helped.

Then and now
AreaOld approachModern behaviour
Class metadataPermGen, fixed MaxPermSizeMetaspace, grows on demand, elastic since JDK 16
Young generation-Xmn or NewRatio chosen by handG1 resizes it to meet the pause goal
Start of old collectionFixed occupancy percentageAdaptive IHOP in G1; ZGC decides on its own
Heap size in containersHard-coded -Xmx per environmentDerived from the container limit
Pause time vs heap sizeGrew with the heapGenerational ZGC keeps pauses short at any size

3What Containers Changed

Since JDK 10, and in later JDK 8 updates, the JVM reads the container's cgroup limits instead of the host's memory and CPU count. That means defaults such as the maximum heap (25 percent of memory unless we say otherwise), the number of GC threads and the choice of collector are derived from what the container is actually allowed to use. A single setting, MaxRAMPercentage, lets us express the heap as a share of the limit, so the same image works in a 2 GiB pod and an 8 GiB pod.

This is the hinge of a modern standard. The quantity that operations controls is the container memory limit. The JVM can work out the rest, as long as we tell it how much of that limit the heap may take.

4What the Company Standard Should Say

A good standard sets the total budget and very little else. It says that every service declares a container memory limit, with request equal to limit, and that the heap is sized with MaxRAMPercentage, typically between 50 and 75 percent, chosen from measurement of each service class. It names the default collector, G1 for most services and generational ZGC where tail latency matters.

It then adds guard limits for areas that can grow without bound and turn a bug into a kernel kill: a MaxMetaspaceSize well above normal use to catch class loader leaks, and a MaxDirectMemorySize to catch direct buffer leaks. These do not tune performance; they make leaks fail with a clear Java error.

Just as important is what the standard forbids without evidence: fixed young sizes, survivor ratios, tenuring thresholds and other internal sizing flags. A team that wants one must show a GC log and a measurement that justify it.

Text
# Standard runtime profile, published in the base image
JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=70 \
-XX:MaxMetaspaceSize=512m \
-XX:MaxDirectMemorySize=256m \
-Xlog:gc*:file=/var/log/app/gc.log:time,uptime:filecount=5,filesize=20m"
# Not allowed without a measured reason:
# -Xmn, -XX:NewRatio, -XX:SurvivorRatio, -XX:MaxTenuringThreshold
Step throughHow a team gets a deviation from the standard
  1. Team proposes a tuning flagFor example a fixed young generation
  2. GC log and load test attached?Evidence from the real service
    YesReview the measurementNoUse the standard profile
  3. Does it beat the default clearly?Latency or cost, measured
    YesApprove for this service and record whyNoKeep the default
  4. Re-check on the next LTSAdaptive behaviour may have caught up

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

The flags live in the shared base image, so a fix reaches every team through one change.

5Keeping the Standard Current

Adaptive behaviour keeps improving with every release. Elastic metaspace arrived in JDK 16, generational ZGC in JDK 21, and recent releases added compact object headers and other memory savings. A flag that helped on JDK 11 may be useless or harmful on JDK 25. So the standard should be reviewed on every LTS upgrade: run the reference services with and without each special flag, delete the ones that no longer pay for themselves, and record the reason for each one that remains.

6Follow-up questions

Is there any internal sizing flag you would still set by default?

A few guard limits, yes: MaxMetaspaceSize and MaxDirectMemorySize, set well above normal use, so leaks fail with a Java error rather than a container kill. I would also make the code cache limit explicit if we budget memory tightly. None of these tune performance; they bound areas that otherwise grow without limit.

What if a team insists its old tuning flags are faster?

I would ask for a comparison on the current JDK with and without the flags, using the same load test. Sometimes they are right, and then we record the exception and why. Often the default wins once the flags stop disabling the adaptive sizing, and the team ends up with fewer settings to maintain.

Why set request equal to limit for memory?

Because the JVM sizes its heap from the limit, and memory cannot be taken back from a running JVM the way CPU time can. If the node is overcommitted and the pod uses more than its request, it becomes a candidate for eviction or a kernel kill. Equal request and limit makes the budget a promise rather than a hope.

7Conclusion

In this answer, we saw that fixed memory areas such as PermGen and hand-sized young generations failed whenever workloads changed, and that the JVM replaced them with pause-goal driven sizing, on-demand metaspace, container awareness and largely self-sizing collectors. A company standard should therefore fix the total budget, the container limit and the heap percentage, add guard limits on leak-prone areas, forbid internal sizing flags without evidence, and be reviewed on each LTS release.

What to say in the interviewAbout 80 seconds aloud

Open with

The reason for the shift is that fixed areas required expert guesses that went stale. PermGen ran out when an app loaded more classes or redeployed, even with free heap, and a hand-sized young generation caused premature promotion and long full GCs once traffic changed.

Then, if they want more

So HotSpot moved to goals and on-demand growth: G1 resizes the young generation to meet a pause target, metaspace grows as needed and since JDK 16 gives memory back, ZGC decides most of its work on its own, and since JDK 10 the JVM reads container limits. My standard would follow that direction.

Every service sets a container memory limit with request equal to limit, and the heap is a percentage of it through MaxRAMPercentage, picked from measurement, usually between half and three quarters. We pick G1 by default and generational ZGC for latency-sensitive services.

We keep guard limits like MaxMetaspaceSize and MaxDirectMemorySize so leaks fail with a clear Java error instead of an OOM kill. We do not allow internal sizing flags such as Xmn or survivor ratios without a GC log and a load test, because those flags switch off the adaptation.

The profile lives in the base image, and we review it on each LTS, since the defaults keep getting better.

About this answer

Last updated
12 November 2026
Versions it names
Java 16, Java 8, Java 10, Java 11
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 "JVM memory management moved from many separately sized areas (a fixed PermGen, fixed...": https://scrivio-interview-library.netlify.app/java/memory-layout/ca0e904fae/