RFR 8220238 : Enhancing j.l.Runtime/System::gc specification with an explicit 'no guarantee' statement

Roger Riggs Roger.Riggs at oracle.com
Fri May 31 17:24:19 UTC 2019

Hi Martin,

True, calling System.gc() and then checking for its hoped-for/expected 
side-effects is the norm.
But its robustness depends on a combination of gc implementation 
behavior and
the particular side-effect expected: allocation, reference processing, etc.


On 05/30/2019 01:30 PM, Martin Buchholz wrote:
> If you are calling System.gc() for correctness (e.g. in a test), it is 
> probably because some sort of finalization is being triggered.  And 
> that happens in some Java thread (e.g. Reference Handler) that 
> System.gc() has no control over.  So in practice, users need to call 
> System.gc() and then wait for subsequent reference processing somehow.

More information about the core-libs-dev mailing list