> > > ...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)