RFR: 8227619: Potential memory leak in javafx.scene.control.ListView
arapte at openjdk.java.net
Fri Feb 7 12:01:35 UTC 2020
On Wed, 5 Feb 2020 23:29:50 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> `ListView` does not get GCed because `SelectedItemsReadOnlyObservableList` adds a `ListChangeListener` to the (`ObservableList`) items of `ListView`.
>> Adding a `WeakListChangeListener` instead of `ListChangeListener` fixes the issue.
>> Added a unit test and verified that existing tests do not fail due to this change.
> Presuming that using a weak reference causes no other issues, the fix looks fine and will resolve the leak. How confident are you that there are no cases where the listener might be prematurely garbage collected?
> How confident are you that there are no cases where the listener might be prematurely garbage collected?
The listener is added by `ListViewBitSetSelectionModel`. The selection model is set only once for a `ListView` and we do not unset it. So the change looks very safe to me.
More information about the openjfx-dev