RFR: 8184166: SortedList does not free up memory [v4]

Andy Goryachev angorya at openjdk.org
Thu Dec 18 16:05:28 UTC 2025


On Thu, 18 Dec 2025 00:28:20 GMT, Cormac Redmond <duke at openjdk.org> 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.
>
> Cormac Redmond has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8184166: Move nulling of out-of-range elements to inside if (c.wasRemoved()) { } block, as this is only where it's required.

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

> 265: 
> 266:                 // Null out out-of-range array elements to avoid maintaining object references
> 267:                 for (int i = size; i < (size + c.getRemovedSize()); i++) {

minor suggestion:

int ct = size + c.getRemovedSize();
for (int i = size; i < ct; i++) {

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

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


More information about the openjfx-dev mailing list