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

Alexey Ivanov aivanov at openjdk.org
Fri Feb 24 21:09:03 UTC 2023


On Fri, 24 Feb 2023 20:08:21 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> There are lots of tests that rely on System.gc() actually triggering a gc.
>> SFAIK all collectors we have today will obey it unless you use
>> -XX:+DisableExplicitGC
>> If you can make the test work with that then that would be interesting but calling just System.gc() is no worse than all those other tests.
>
> Many client tests generate OOM for that, we have a special Util, see the usage of Util.generateOOME() or various implementation of generateOOME.
> 
> If the OOM + sleep(to give the GC a chance to clean the weakrefs in case of slow systems) does not work, then could it be considerred as a GC bug?
> 
>>OutOfMemoryError: The Java Virtual Machine implementation has run out of either virtual or physical memory, and the automatic storage manager was unable to reclaim enough memory to satisfy an object creation request.
> https://docs.oracle.com/javase/specs/jvms/se19/html/jvms-6.html#jvms-6.3

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

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

Calling `System.gc()` conveys the intent in a clearer way. No OOME is required.

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

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



More information about the client-libs-dev mailing list