On Sun, 7 Dec 2025 01:36:02 GMT, Cormac Redmond <[email protected]> wrote:

> Fix SortedList memory leak by clearing unused entries in the internal array 
> when the source list shrinks. Also nullify tempElement.e after use,
> 
> Adding 
> "--add-opens=javafx.base/javafx.collections.transformation=ALL-UNNAMED" to 
> allow reflection access from tests.

modules/javafx.base/src/main/java/javafx/collections/transformation/SortedList.java
 line 280:

> 278: 
> 279:         // Null out out-of-range array elements to avoid maintaining 
> object references
> 280:         for (int i = size; i < sorted.length; i++) {

Don't we need to null the unused entries only when the `sorted` array shrinks 
(i.e. when the `size` is reduced)?

so all we do is to handle L259 case `if (c.wasRemoved())` since everywhere else 
the references are null'ed (L379, L388)?

modules/javafx.base/src/test/addExports line 14:

> 12: --add-opens javafx.base/javafx.beans.value=ALL-UNNAMED
> 13: --add-opens=javafx.base/javafx.collections.transformation=ALL-UNNAMED
> 14: #

we probably should add a newline char at the end of L14

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2000#discussion_r2628961363
PR Review Comment: https://git.openjdk.org/jfx/pull/2000#discussion_r2628963800

Reply via email to