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

Alexey Ivanov aivanov at openjdk.org
Thu Feb 23 20:16:39 UTC 2023


On Fri, 17 Feb 2023 00:26:30 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> For this reason, GC logs are enabled. If, for whatever reason, the call to `System.gc()` is ignored, we'll see it in the test log. Then a specific GC could be selected, for example, or another fix implemented.
>> 
>> OOME does not guarantee a full GC cycle either.
>> 
>> Having the above in mind, I'd rather keep it simple.
>
>>For this reason, GC logs are enabled. If, for whatever reason, the call to System.gc() is ignored, we'll see it in the test log. Then a specific GC could be selected, for example, or another fix implemented.
> 
> As of now this test can be executed with different GC, and some of them can skip System.gc().
> 
>>OOME does not guarantee a full GC cycle either.
> 
> But it guarantee that at least some GC will be always run, unlike System.gc().

I followed the piece of advice in the [JBS comment](https://bugs.openjdk.org/browse/JDK-8300727?focusedCommentId=14560139&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14560139).

If using `System.gc()` is good enough for testing references:

https://github.com/openjdk/jdk/blob/f612dcfebea7ffd4390f833646ad45d6f0ebd04f/test/jdk/java/lang/ref/ReferenceEnqueue.java#L54-L60

https://github.com/openjdk/jdk/blob/f612dcfebea7ffd4390f833646ad45d6f0ebd04f/test/jdk/java/lang/ref/PhantomReferentClearing.java#L85-L92

Then it should be good enough for this test too.

Perhaps, the same effect could be achieved by causing OOME in a loop. However, using `System.gc()` makes the intention clearer: *run GC*, wait for the phantom reference to be cleared and enqueued.

I can explicitly select a GC: `-XX:+UseG1GC` (default) or `-XX:+UseSerialGC`.

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

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



More information about the client-libs-dev mailing list