RFR: 8293282: LoadLibraryUnloadTest.java fails with "Too few cleared WeakReferences"

Roger Riggs rriggs at openjdk.org
Fri Sep 9 15:06:50 UTC 2022


On Thu, 8 Sep 2022 20:54:28 GMT, Mandy Chung <mchung at openjdk.org> wrote:

>> Modify the LoadLibraryUnload test to call gc() more a few times, allowing multiple gc cycles to queue the expected refs.
>> Short the timeout on each cycle to 10 sec.
>
> test/jdk/java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java line 171:
> 
>> 169:                 dequeueCount++;
>> 170:         }
>> 171:         Asserts.assertEquals(dequeueCount, LOADER_COUNT, "Too few cleared WeakReferences");
> 
> This only invokes GC `LOADER_COUNT` times.  I think you may want something like what ForceGC does:
> 
> 
>         int retries = (int)(Math.round(1000L * TIMEOUT_FACTOR) / 200);
>         for (; retries >= 0; retries--) {
>             if (dequeueCount == LOADER_COUNT) return;
>             
>             System.gc();
>             refQueue.remove(200L);
>         }

I'll switch to using ForceGC.wait to wait for all the WeakReferences to be cleared.
Using existing logic for the gc and timing.

-------------

PR: https://git.openjdk.org/jdk/pull/10223


More information about the core-libs-dev mailing list