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

Peter Levart peter.levart at gmail.com
Thu May 30 05:50:43 UTC 2019


On 5/29/19 9:25 PM, Roger Riggs wrote:
> Any other comments on:
> "* Runs the garbage collector in the Java Virtual Machine.
> * <p>
> * Calling this method suggests that the Java Virtual Machine
> * expend effort toward recycling unused objects in order to
> * make the memory they currently occupy available for reuse
> * by the Java Virtual Machine.

The following two statements...

> * When control returns from the method call, the Java Virtual Machine
> * has made a best effort to reclaim space from all discarded objects.

> * There is no guarantee that this effort will recycle any particular
> * number of unused objects, reclaim any particular amount of space,
> * *or complete* at any particular time, if *at all*.
> " 

...makes one think that it is OK (by the spec) for System.gc() to never 

Could it rather be specified that System.gc() eventually completes?

Regards, Peter

More information about the core-libs-dev mailing list