On Mon, 17 Aug 2026 21:18:46 GMT, Kevin Rushforth <[email protected]> wrote:
>> modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/SelectedItemsReadOnlyObservableList.java >> line 40: >> >>> 38: private final ObservableList<Integer> selectedIndices; >>> 39: private final Supplier<Integer> modelSizeSupplier; >>> 40: private final List<WeakReferenceWrapper<E>> itemsRefList; >> >> This is still confusing me as also mentioned in the ticket. For example, the >> `SelectionModel` has a `selectedItem` property, where we save the item >> `<T>`. So the item `T` is saved, without any `WeakReference` handling. >> >> And this is used in e.g. `ComboBox`, which does not seems to leak memory. So >> I wonder why we use a `WeakReference` here. >> >> The `WeakReference` usage in the `TableCell` is also questionable. >> Maybe worth to research in a follow-up? > > Yes, this is definitely worth a follow-up. > > This is a very odd use of weak references. It's a short-lived list of > previously removed items used in a subsequent change event. > > Dan Smith @dlsmith-dev suggested something similar in this thread: > > https://mail.openjdk.org/archives/list/[email protected]/thread/TD7AQH4SNRS4QAQAXTISKIERNK6LINYB/ > > The use of weak references suggests that when this was implemented, they were > worried about a possible leak, so we would need to show that it can't leak in > practice. > > If we can prove using strong references won't lead to a leak, that would be > the best solution anyway. I filed [JDK-8390875](https://bugs.openjdk.org/browse/JDK-8390875) and [JDK-8390878](https://bugs.openjdk.org/browse/JDK-8390878) to track the follow-up issues. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2250#discussion_r3832302752
