RFR 8220238 : Enhancing j.l.Runtime/System::gc specification with an explicit 'no guarantee' statement
Martin Buchholz
martinrb at google.com
Mon Jun 3 21:57:17 UTC 2019
>
>
> ...there is an internal API
> (java.lang.ref.Reference#waitForReferenceProcessing) and a usage of it
> (java.nio.Bits#reserveMemory)
>
Big picture: there is a need both within and outside jdk proper to manage
non-heap-memory resources in Java, and we still have no good answer.
Reference#waitForReferenceProcessing is private, and it would be
uncomfortable to make it public, in part because it is unreliable.
reserveMemory might fail if System.gc() returned immediately (merely
starting an asynchronous full gc) and the subsequent full gc took more than
a second (as it is known to do).
We could improve reliability with great effort, including additional APIs
like initiateReferenceDiscovery (maybe returning a CompletableFuture)
More information about the core-libs-dev
mailing list