JimmyJames
JimmyJames

Reputation: 1403

(NOT) Netty calls to System.gc()

When reviewing GC logs for an application which is built upon, Netty, I noticed that there were GC events tagged with 'System.gc()' e.g.:

[GC (System.gc()) [PSYoungGen: 63506K->64K(637952K)] 126048K->62605K(2036224K), 0.0035823 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 
[Full GC (System.gc()) [PSYoungGen: 64K->0K(637952K)] [ParOldGen: 62541K->62541K(1398272K)] 62605K->62541K(2036224K), [Metaspace: 82261K->82261K(1120256K)], 0.1926316 secs] [Times: user=0.47 sys=0.00, real=0.19 secs] 

Upon a search of the code and the libraries in use, we have determined that these calls are coming from Netty (version 4.1.21 final).

I have not been able to find anything in the documentation or by searching that refers to this. Is there anywhere I can read about why this is being done and what impact disabling explicit GC might have? All I have been able to find is this presentation which notes something about System.gc() but has no useful information about it.

In the events I saw, it seemed that the GC was done at a sub-optimal time and that it executed a full-GC when none was needed and appears to have moved objects to the old generation unnecessarily.

CORRECTION: This was initially attributed to Netty but on further inspection it was found not to be the case. Netty does not make calls to System.gc().

Upvotes: 2

Views: 380

Answers (1)

Norman Maurer
Norman Maurer

Reputation: 23567

There is no System.gc() call triggered by netty itself. Just search the code-base there is nothing like this. That said the JVM may try to call System.gc() when you try to allocate a direct buffer and there is not enough memory left.

If this is the source of the System.gc() I would suggest to higher the max amount of direct memory the JVM is allowed to us.

Upvotes: 2

Related Questions