RFR: 8300727: java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java failed with "List wasn't garbage collected"
Sergey Bylokhov
serb at openjdk.org
Fri Mar 3 00:54:11 UTC 2023
On Thu, 2 Mar 2023 12:20:24 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
> Do you agree that using only `System.gc` is more concise than generating OOME?
> If `System.gc` is enough for testing `Reference` classes, why does the client libs team need to generate OOME? Our tests use the `Reference` classes to check if an object is garbage-collected.
I prefer to use OOM just based on the text of the specification I referred above. As per the spec, both should trigger some cleanup, but System.gc could be ignored. If we would like to change that approach then let's add a retry to this test first. Maybe the test will continue to fail if we will add just a retry. Isn't it suspicious that it started to fail now? and then replace the usage/implementation of generateOOM method by system.gc() everywhere.
> I already answered this question several times. 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): _“This is not the way to provoke a full GC in a test reliably. Just use System.gc(). See e.g. [`test/jdk/java/lang/ref/PhantomReferentClearing.java`](https://github.com/openjdk/jdk/blob/master/test/jdk/java/lang/ref/PhantomReferentClearing.java).”_
>
> That's what I did. Using `System.gc()` proved to be successful and, in my opinion, it looks cleaner than generating OOME.
But why we did not ask why "This is not the way to provoke a full GC in a test reliably"? It does not work as specified?
-------------
PR: https://git.openjdk.org/jdk/pull/12594
More information about the client-libs-dev
mailing list