Scrivio Interview library
InternalsFoundations6 min read · updated 12 November 2026

Describe a G1 collection cycle: young collections, concurrent marking, and mixed collections. What does MaxGCPauseMillis influence?

G1 runs young collections that evacuate live objects from eden and survivor regions in a stop-the-world pause. When old occupancy passes the initiating heap occupancy threshold, which is adaptive by default, it starts concurrent marking with short pauses for the start, remark and cleanup, and then runs mixed collections that evacuate young regions plus the old regions with the most garbage, over several pauses. MaxGCPauseMillis, 200 ms by default, is a target that G1 meets by sizing the young generation and choosing how many old regions go into each mixed pause; if evacuation cannot keep up, G1 falls back to a full GC, which has been parallel since JDK 10.

Background to this question

G1 is the default collector on most JVMs, so its logs are the ones we read most often. Every line names a phase of its cycle: Pause Young (Normal), Concurrent Mark Cycle, Pause Remark, Pause Young (Mixed). Knowing the cycle turns those lines from noise into a story about the application's memory. In this answer, we will recap how G1 lays out the heap, follow one full cycle from young collections through concurrent marking to mixed collections, see what MaxGCPauseMillis really controls, and look at the fallback when things go wrong.

1A Quick Recap of the G1 Heap

G1 divides the heap into equal-sized regions, usually 1 to 32 MB, around 2,048 of them. Each region has a role at a given time: eden, where new objects are allocated; survivor, holding objects that survived a young collection; old, holding long-lived objects; or humongous, for very large objects. Roles change: an empty region can become eden now and old later.

Collection in G1 is evacuation. To collect a set of regions, called the collection set, G1 copies their live objects into other free regions and then frees the whole source region. Copying compacts the data as a side effect, so G1 does not suffer the fragmentation that the old CMS collector did.

2Young Collections

When the eden regions are full, G1 stops the application and runs a young collection. The collection set is all eden and survivor regions. Live objects are found from the roots and from the remembered sets, which record old-to-young pointers, and are copied into new survivor regions, or into old regions if they have survived enough collections, controlled by the tenuring threshold.

This is the line we see most in a G1 log: Pause Young (Normal) (G1 Evacuation Pause). A healthy young pause on a service with a few gigabytes of heap typically takes 5 to 50 ms, and its cost depends on how much survives, not on how big eden was.

3Concurrent Marking

Young collections never clean up old regions, so the old part of the heap slowly fills with objects that were promoted and later died. G1 has to find out which old objects are still live. It does this with concurrent marking, which runs alongside the application.

Marking starts when old occupancy crosses the initiating heap occupancy percent, IHOP. The static default is 45 percent of the heap, but with adaptive IHOP, which is on by default, G1 learns how long marking takes and how fast the old generation fills, and starts early enough that marking finishes before the heap runs out.

The cycle has three short pauses. Concurrent Start piggybacks on a young pause and marks the roots. Then marking threads trace the old regions while the application runs. Remark is a short pause that finishes marking and processes references. Cleanup is another short pause that updates region statistics and frees regions that turned out to be completely empty. After this, G1 knows how much live data each old region holds.

Step throughOne G1 cycle
  1. Young collectionsevacuate eden and survivors; repeat
  2. Old occupancy above IHOP?
    YesStart concurrent markingNoKeep running young collections
  3. Pause Young (Concurrent Start)a young pause that also marks the roots
  4. Concurrent marktrace old regions while the application runs
  5. Pause Remark, then Pause Cleanupfinish marking, rank old regions by garbage
  6. Pause Young (Prepare Mixed)last young-only pause before mixed collections
  7. Pause Young (Mixed) x severalyoung regions plus the most garbage-filled old ones
  8. Candidates used up or not worth it?
    YesBack to young-only collectionsNoAnother mixed collection

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

Pause names are those of JDK 17 and later logs; earlier releases used slightly different wording.

4Mixed Collections

Now G1 has a list of candidate old regions, sorted by how much garbage they contain. A region that is 90 percent garbage is cheap to evacuate, because only 10 percent must be copied, and frees a lot. A region that is 85 percent live or more is not worth collecting at all and is left out.

Instead of collecting all candidates in one long pause, G1 spreads them across several mixed collections, by default aiming for up to 8. Each mixed collection is a young collection plus a slice of the candidate old regions. When the remaining candidates would free less than a small share of the heap, 5 percent by default, G1 stops and goes back to young-only collections until the next marking cycle.

5What MaxGCPauseMillis Influences

MaxGCPauseMillis, 200 ms by default, is a goal, not a guarantee. G1 keeps statistics on how long it takes to copy a megabyte, scan a card, and so on, and uses them to predict pause time. It then adjusts two things: the size of the young generation, and how many old regions it adds to each mixed collection.

Java
-XX:MaxGCPauseMillis=200 // default: young gen can grow until predicted pauses near 200 ms
-XX:MaxGCPauseMillis=50 // smaller young gen, more frequent and shorter young pauses,
// fewer old regions per mixed pause, more mixed pauses
-Xmn2g // fixes young size: G1 can no longer adapt it to meet the goal

So a lower target gives more frequent, shorter pauses and usually slightly lower throughput. Notice the last line: fixing the young generation with -Xmn or NewSize takes away G1's main lever, which is why we avoid it on G1.

6When Evacuation Cannot Keep Up

If the application allocates or promotes faster than mixed collections reclaim old space, G1 can run out of free regions to copy into. The young pause then reports an evacuation failure, and if no space is recovered, G1 falls back to a full GC, Pause Full (G1 Compaction Pause), which compacts the whole heap while the application is stopped.

Since JDK 10 (JEP 307) this full GC uses parallel threads, so it is much faster than the old single-threaded version, but on a large heap it still takes seconds. A full GC in a G1 log means the heap is too small for the live data, marking started too late, or humongous allocations fragmented the heap.

7Follow-up questions

Why is G1 called garbage first?

Because during mixed collections it collects the old regions with the most garbage first. Those regions give the most free space for the least copying work, so within a pause budget G1 reclaims as much as possible. The name describes the region selection, not the order of young and old collections.

Does concurrent marking stop the application?

Only for the short pauses at its start, remark and cleanup, which are usually a few milliseconds to a few tens of milliseconds. The tracing itself runs on concurrent GC threads alongside the application, taking CPU but not stopping it. The number of those threads is set by ConcGCThreads, which defaults to about a quarter of ParallelGCThreads.

Why do mixed collections not collect all candidates in one pause?

Because that pause could be much longer than the target. By splitting the work over several mixed collections and choosing the cheapest regions first, G1 keeps each pause near MaxGCPauseMillis while still reclaiming the old generation within a few collections.

8Conclusion

In this answer, we followed a G1 cycle. Young collections evacuate eden and survivor regions in short pauses. When old occupancy passes the adaptive IHOP threshold, G1 marks concurrently with short pauses for concurrent start, remark and cleanup, and learns how much garbage each old region holds. Mixed collections then evacuate young regions plus the most garbage-filled old regions over several pauses. MaxGCPauseMillis, 200 ms by default, steers the young generation size and the number of old regions per mixed pause, and if evacuation cannot keep up, G1 falls back to a parallel full GC.

What to say in the interviewAbout 90 seconds aloud

Open with

G1 splits the heap into equal regions that can be eden, survivor, old or humongous, and it collects by evacuating live objects out of a set of regions.

Then, if they want more

The common case is a young collection: when eden fills up, it stops the application, copies live objects from eden and survivor regions into new survivor or old regions, and frees the old ones.

Old regions fill up over time, so when old occupancy passes the initiating heap occupancy threshold, which is adaptive by default with a 45 percent starting point, G1 starts concurrent marking.

That has a concurrent start piggybacked on a young pause, then tracing while the application runs, then short remark and cleanup pauses, after which G1 knows how much garbage each old region holds. Then it runs mixed collections, each one a young collection plus the old regions with the most garbage, spread over several pauses.

That is why it is called garbage first. MaxGCPauseMillis, 200 milliseconds by default, is a target: G1 predicts pause cost and sizes the young generation and the number of old regions per mixed pause to meet it, which is why I would not fix the young size with -Xmn.

If evacuation runs out of space, G1 falls back to a full GC, parallel since JDK 10 but still slow on large heaps.

About this answer

Last updated
12 November 2026
Versions it names
Java 10
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 "Describe a G1 collection cycle: young collections, concurrent marking, and mixed...": https://scrivio-interview-library.netlify.app/java/garbage-collection/7ab4e38a99/