On Fri, 1 Jul 2022 08:12:59 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
>> True, knowing when GC is 'done' is not deterministic except for a specify >> Reference to a specific object. >> System.gc is just a request, the checking for an object can more quickly >> exit the loop. >> The code is as is, and already commented, might wait an extra cycle, but >> only in the case of a race between the requested predicate and the object >> being reclaimed. Ok as it. > > Maybe not for this PR - but it could be useful to have a version of ForceGC > that takes as parameter a ReferenceQueue<T> and a Reference<T>. That would be > more efficient than creating a new object and waiting for a different cleaner > thread to cleanup that object. @dfuch Taking a reference as parameter could simplify the use of ForceGC. I though about this idea as well, when I had to check lambada expressions in each call. I would like to do it in the future so that this PR could focus on less things. ------------- PR: https://git.openjdk.org/jdk/pull/8979