https://bugs.kde.org/show_bug.cgi?id=520075

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REPORTED                    |RESOLVED
         Resolution|---                         |FIXED
      Latest Commit|                            |https://invent.kde.org/netw
                   |                            |ork/kdeconnect-android/-/co
                   |                            |mmit/ef26a62d1fff566792ccf5
                   |                            |a836ed4d491af9b11b

--- Comment #2 from [email protected] ---
Git commit ef26a62d1fff566792ccf5a836ed4d491af9b11b by Juan Camilo Nieves.
Committed on 12/05/2026 at 16:29.
Pushed by albertvaka into branch 'master'.

Fix memory leak in DeviceFragment from duplicate callback registration

When onViewCreated() is invoked more than once on the same Fragment
instance (which can happen during certain fragment transactions),
addPairingCallback() and addPluginsChangedListener() append a second
entry to the underlying CopyOnWriteArrayList in Device. The matching
removeXxxCallback() in onDestroyView() only removes the first
occurrence, leaving the Fragment retained via the second entry.

Defensively remove the callback before adding it, so that a second
invocation of onViewCreated() does not accumulate duplicates.

Verified empirically by:
1. Navigate to DeviceFragment, back, then navigate again.
2. Capture heap dump via Android Studio Profiler.
3. Before: 2 DeviceFragment instances, one orphaned with
   pluginsChangedListener and pairingCallback still in its fields,
   retained through the CopyOnWriteArrayList backing array.
4. After: 1 DeviceFragment instance, orphan collected by GC.

M  +2    -0    src/main/java/org/kde/kdeconnect/ui/DeviceFragment.kt

https://invent.kde.org/network/kdeconnect-android/-/commit/ef26a62d1fff566792ccf5a836ed4d491af9b11b

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to