RFR: 8300727: java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java failed with "List wasn't garbage collected"

Sergey Bylokhov serb at openjdk.org
Sun Feb 26 05:25:03 UTC 2023


On Thu, 16 Feb 2023 14:38:21 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> The test has become unstable recently, there were quite a few failures, on Windows mostly. I was lucky enough to find a host where the test failed consistently.
> 
> I call `System.gc()` directly as suggested in comments to the bug. I used `PhantomReference` instead of `WeakReference`.
> 
> Now the test calls `System.gc()` in a loop and waits for the reference to be enqueued. In majority of cases, the test exits the loop at the second attempt.

> Yes, I saw this method, and [it periodically calls System.gc()](https://github.com/openjdk/jdk/blob/b4ea80731c6c0a0328a9801590ba5b081f08c3bd/test/jdk/javax/swing/regtesthelpers/Util.java#L102-L103).

It generates OOM to make sure that gc will be called, unlike System.gc() which per the spec can be ignored.

> I still don't understand your concern. How is generating OutOfMemoryError better than calling System.gc()?

That method uses both, which I suggested doing at the start. It is better to follow one approach than implement different patterns here and there.

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

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



More information about the client-libs-dev mailing list