Scrivio Interview library
DebuggingIntermediate6 min read · updated 12 November 2026

A service's GC log shows this line once an hour, every hour: GC(310) Pause Full (System.gc()) 2900M->2100M(4096M) 2412.771ms. What are the likely causes and how do you fix it?

The cause System.gc() means code explicitly asked for a full GC; heap pressure did not trigger it. An exact hourly rhythm points to RMI's distributed garbage collector, which calls System.gc() once an hour by default whenever RMI is in use, for example for remote JMX; other sources are libraries that call System.gc() and direct buffer allocation, which calls it when direct memory runs out. We find the caller with a JFR recording or a thread dump or breakpoint, fix or reconfigure it, and can make the call cheaper with -XX:+ExplicitGCInvokesConcurrent, which runs a G1 concurrent cycle instead, while -XX:+DisableExplicitGC ignores the call but can break direct buffer reclamation.

Why this question is asked

A 2.4 second pause every hour, like clockwork, is one of the easier GC mysteries to solve, as long as we read the cause in the log line. Many teams first try heap tuning, which cannot help, because heap pressure is not what triggers it. Interviewers ask this to see whether we read the log carefully and know the classic sources of explicit GC. In this answer, we will read the line, look at why System.gc() leads to a full GC, go through the likely callers, find the one in our service, and then compare the fixes.

1Reading the Line

The line is GC(310) Pause Full (System.gc()) 2900M->2100M(4096M) 2412.771ms. Pause Full means a full, stop-the-world collection of the whole heap. The cause in parentheses, System.gc(), tells us why: some code called System.gc() or Runtime.getRuntime().gc().

The numbers show it was not needed. Before the collection 2,900 MB of a 4,096 MB heap was used, so 1.2 GB was still free, and G1 would have reclaimed the garbage in its normal young and mixed collections. Instead, G1 compacted the whole heap, with 2,100 MB of live data, in 2.4 seconds while the application was stopped.

2Why System.gc() Means a Full GC

System.gc() is a request to the JVM to collect garbage. For G1, Parallel and Serial, the default response is a full, stop-the-world compaction of the whole heap, because that is the only way to guarantee everything collectable has been collected. With ZGC and Shenandoah, the request runs as a concurrent cycle instead.

So the question is not how to tune the heap. It is who is calling System.gc() once an hour.

3The Usual Suspects

The hourly rhythm is the strongest clue. Java RMI, remote method invocation, has a distributed garbage collector: to clean up remote objects, it periodically forces a local GC so unreachable remote references are found. The interval is controlled by two system properties, sun.rmi.dgc.client.gcInterval and sun.rmi.dgc.server.gcInterval, and both default to 3,600,000 ms, one hour.

Few services use RMI directly, but many use it indirectly through remote JMX. Starting the JVM with com.sun.management.jmxremote.port, so a monitoring tool or JConsole can connect, starts an RMI connector, and the hourly GC comes with it.

Other sources call System.gc() less regularly. Some libraries and application servers call it, for example after a redeploy or a cache flush. Direct buffer allocation, ByteBuffer.allocateDirect, calls System.gc() when the direct memory limit is reached, hoping that collecting dead buffer objects frees their native memory; that call follows load rather than the clock.

Who calls System.gc()
SourcePattern in the logClue
RMI distributed GCexactly every hourremote JMX or RMI enabled
Direct buffer limit reachedbursts under I/O loadNetty or NIO heavy, MaxDirectMemorySize
Library or frameworkafter deploys, flushes, jobsstack trace points to a library
Our own codeanywheregrep the code base for System.gc

4Finding the Caller

We confirm the source instead of guessing. The quickest checks are the configuration, to see whether remote JMX or RMI properties are set, and the code, by searching for System.gc in our own code base. To catch the actual caller, a JFR recording around the hour helps; recent JDKs record System.gc() calls as an event with a stack trace, so check your version. A thread dump taken around the hour also shows the RMI daemon thread that triggers the collection, if RMI is the source.

Shell
$ jcmd 4711 VM.system_properties | grep -E 'jmxremote|rmi'
com.sun.management.jmxremote.port=9010 // remote JMX is on, so RMI is active
$ jcmd 4711 Thread.print | grep -i 'gc daemon'
"RMI GC Daemon" #31 daemon prio=2 ... // the thread that calls System.gc() hourly (name may vary)
$ jcmd 4711 JFR.start duration=2h filename=/tmp/gc.jfr // then look for the System GC event and its stack

If the stack trace shows a library instead, we fix it in the library's configuration or upgrade it. If it shows direct buffer allocation, the real problem is direct memory sizing, and the fix is in MaxDirectMemorySize or buffer pooling, not in suppressing the call.

5Fixing It

For the RMI case there are three good options. We can stop using remote JMX if nothing needs it, for example by exposing metrics through Micrometer and Prometheus instead. We can raise the RMI intervals, for example to a day. Or we can keep the calls but make them cheap with -XX:+ExplicitGCInvokesConcurrent, which tells G1 to answer System.gc() with a concurrent marking cycle instead of a full stop-the-world compaction.

Java
-Dsun.rmi.dgc.client.gcInterval=86400000 // RMI distributed GC once a day instead of hourly
-Dsun.rmi.dgc.server.gcInterval=86400000
-XX:+ExplicitGCInvokesConcurrent // System.gc() starts a concurrent G1 cycle: short pauses only
// log afterwards: Pause Young (Concurrent Start) (System.gc()) ... a few ms
-XX:+DisableExplicitGC // System.gc() does nothing at all (use with care)

DisableExplicitGC is the bluntest tool, and it has a catch. Native memory behind direct buffers is freed only when the buffer objects are found unreachable by the GC. When direct memory runs out, the JDK calls System.gc() to find and free dead buffers; with DisableExplicitGC that call does nothing, and the service can fail with OutOfMemoryError: Direct buffer memory even though most buffers are dead. ExplicitGCInvokesConcurrent keeps that safety net while removing the long pause, so it is usually the better choice.

6Follow-up questions

Which RMI system properties control the distributed GC interval?

sun.rmi.dgc.client.gcInterval and sun.rmi.dgc.server.gcInterval, both in milliseconds, with a default of 3,600,000, one hour. The client property applies when the JVM holds references to remote objects, the server property when it exports remote objects. Setting both, for example to 86400000 for a day, spaces out the forced collections; RMI uses the shortest interval requested across the JVM.

Why was the full GC so slow?

A G1 full GC marks and compacts the whole heap while the application is stopped. With 2,100 MB of live data to process, even with parallel threads it took 2.4 seconds. Normal G1 collections never process the whole heap at once, which is why they are so much shorter.

Would this happen with ZGC?

The call would still come every hour, but ZGC treats System.gc() as a request for a concurrent collection, so it would cause extra GC work and CPU, not a 2.4 second pause.

7Conclusion

In this answer, we saw that the System.gc() cause means code explicitly requested a full GC, which G1 performs as a whole-heap stop-the-world compaction. An exact hourly rhythm points to RMI's distributed GC, active with remote JMX, whose default interval is one hour; libraries and direct buffer allocation are other callers. We found the caller through configuration, thread dumps and JFR, and fixed it by removing remote JMX, raising the RMI intervals, or using -XX:+ExplicitGCInvokesConcurrent, while treating -XX:+DisableExplicitGC with care because it can break direct buffer reclamation.

What to say in the interviewAbout 80 seconds aloud

Open with

The cause in the line is System.gc(), so this is not heap pressure: code explicitly asked for a collection, and G1 answers that by default with a full stop-the-world compaction, here 2.4 seconds to compact 2.1 GB of live data while 1.2 GB was still free.

Then, if they want more

The exact hourly rhythm is the big clue. RMI's distributed garbage collector forces a local GC on an interval set by sun.rmi.dgc.client.gcInterval and server.gcInterval, which default to one hour, and RMI is active in many services just because remote JMX is enabled with jmxremote.port.

Other possible callers are libraries that call System.gc, and direct buffer allocation, which calls it when the direct memory limit is reached, but those would not be so regular.

I would confirm it: check the system properties for jmxremote, take a thread dump to look for the RMI GC daemon thread, and use JFR to get the stack of the System.gc call.

Then fix it: drop remote JMX if metrics already come through Micrometer, or raise the RMI intervals to a day, or add -XX:+ExplicitGCInvokesConcurrent so System.gc becomes a concurrent G1 cycle with only short pauses. I would avoid DisableExplicitGC unless I am sure, because it also disables the safety net that frees direct buffer memory.

About this answer

Last updated
12 November 2026
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 "A service's GC log shows this line once an hour, every hour: GC(310) Pause Full...": https://scrivio-interview-library.netlify.app/java/garbage-collection/db4c96638a/