SUMMARY ======= kwin_wayland leaks one kde_output_device_mode_v2 resource per advertised mode every time a client re-binds the output device, and the resources are never freed. OutputDeviceV2InterfacePrivate::kde_output_device_v2_release() destroys only the output device resource itself. The kde_output_device_mode_v2 resources created for that resource in sendNewMode() are never destroyed, so every re-bind leaks one server-side wl_resource (plus its QtWaylandServer wrapper) per advertised mode. Wayland has no automatic parent-to-child resource lifecycle, so they are orphaned until the client disconnects. libkscreen-based clients re-bind on every configuration re-sync: kded6 (the kscreen module) and powerdevil were observed re-binding continuously, so kwin_wayland leaks in proportion to output-configuration churn. OBSERVED IMPACT =============== Live system: kwin 6.7.4, 13 days uptime, single 3440x1440 output advertising 42 modes. - kwin_wayland RSS ~2.2 GB (normal for this setup: ~0.3 GB), peak 2.46 GB RSS plus 3.68 GB swap. - gcore + glibc heap walk: 11.0 million chunks, of which 3,682,292 chunks of 144 bytes are kde_output_device_mode_v2 wl_resources, and 1.93 million chunks of 48 bytes are the matching QtWaylandServer wrappers. Together that is 87% of all live heap (757 MB). - Every leaked resource's wl_client back-pointer resolves to one of exactly two clients: pid 11151 (kded6) and pid 11194 (powerdevil), both libkscreen users. - Secondary accumulation in the same re-sync loop (small): 87k wl_output::Resource wrappers, 57k zxdg_output_v1::Resource, 58k wp_image_description_v1::Resource. - Growth is bursty, tracking output-configuration churn: flat for hours, then steps of +35 MB (screen blank/dim) and up to +440 MB (observed while kwin was stalled under ptrace and both daemons re-synced for its duration). REPRODUCER ========== The leak requires a long-lived client that re-binds without disconnecting; short-lived tools like "kscreen-doctor --outputs" do NOT leak, because client disconnect destroys all its wl_resources. In a normal session kded6 and powerdevil do this continuously. To reproduce quickly, force output-configuration churn so the daemons re-sync (each apply triggers an atomic commit and a configChanged round through both daemons): for i in {1..8}; do kscreen-doctor output.HDMI-A-1.mode.1 sleep 4 kscreen-doctor output.HDMI-A-1.mode.2 sleep 4 done ps -o rss= -C kwin_wayland (adjust output name and mode ids to your setup) Unpatched, this grows kwin_wayland RSS by tens to hundreds of MB per batch (observed bursts of +35 MB to +440 MB during display transitions). SOURCE (v6.7.4, src/wayland/outputdevice_v2.cpp) ================================================ - kde_output_device_v2_bind_resource() calls sendNewMode(resource, mode) for each mode; sendNewMode() -> createResource() creates one new ModeResource per mode per bind. - kde_output_device_v2_release() calls wl_resource_destroy() on the device resource only; the ModeResources created for it are orphaned. SUGGESTED FIX ============= Destroy the mode resources belonging to the released resource in kde_output_device_v2_release(), using the same send_removed() + wl_resource_destroy() pattern as ~OutputDeviceModeV2InterfacePrivate() and updateModes(). Patch attached (verified: 8 alternating mode switches, RSS 267.5 MB -> 265.7 MB, no protocol errors from either daemon). Note: master stopped advertising the kde-output-device-v2 globals (commit 7e32e00c88a5122e7935827e34a6d61fefd5a5ac), but the protocol implementation and this leak are still present there, and Plasma 6.7.x ships it in production use.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/9855
Git commit 12a066c05a457e58a2bbc118abf2347ed73c93dc by Vlad Zahorodnii, on behalf of Steven Naumov. Committed on 11/09/2026 at 18:03. Pushed by vladz into branch 'master'. wayland: destroy mode resources when the output device resource is released OutputDeviceV2InterfacePrivate::kde_output_device_v2_release() destroyed only the output device resource itself. The kde_output_device_mode_v2 resources created for it in sendNewMode() were never destroyed, so whenever an output device resource is destroyed and a new one advertised to a bound client, one resource per advertised mode leaks until the client disconnects. Measured on a system with a single output advertising 42 modes: after 13 days of uptime, 3.66 million leaked ModeResource objects (~760 MB of live heap), all owned by two long-lived libkscreen clients (the kscreen kded module and powerdevil), accumulating in bursts of up to 440 MB during output churn episodes such as screen blanking and failed atomic commits retrying. Destroy the mode resources belonging to the released resource, following the same send_removed() + wl_resource_destroy() pattern the mode destructor and updateModes() already use. M +16 -0 src/wayland/outputdevice_v2.cpp https://invent.kde.org/plasma/kwin/-/commit/12a066c05a457e58a2bbc118abf2347ed73c93dc
Git commit 2dad5484a6c56f480e7c35aa6f4cd6fc0d44ff92 by Vlad Zahorodnii. Committed on 14/09/2026 at 10:21. Pushed by vladz into branch 'Plasma/6.8'. wayland: destroy mode resources when the output device resource is released OutputDeviceV2InterfacePrivate::kde_output_device_v2_release() destroyed only the output device resource itself. The kde_output_device_mode_v2 resources created for it in sendNewMode() were never destroyed, so whenever an output device resource is destroyed and a new one advertised to a bound client, one resource per advertised mode leaks until the client disconnects. Measured on a system with a single output advertising 42 modes: after 13 days of uptime, 3.66 million leaked ModeResource objects (~760 MB of live heap), all owned by two long-lived libkscreen clients (the kscreen kded module and powerdevil), accumulating in bursts of up to 440 MB during output churn episodes such as screen blanking and failed atomic commits retrying. Destroy the mode resources belonging to the released resource, following the same send_removed() + wl_resource_destroy() pattern the mode destructor and updateModes() already use. (cherry picked from commit 12a066c05a457e58a2bbc118abf2347ed73c93dc) Co-authored-by: Steven Naumov <steven01804@gmail.com> M +16 -0 src/wayland/outputdevice_v2.cpp https://invent.kde.org/plasma/kwin/-/commit/2dad5484a6c56f480e7c35aa6f4cd6fc0d44ff92
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/9968
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/9969
A possibly relevant merge request was started @ https://invent.kde.org/plasma/libkscreen/-/merge_requests/336
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/7083
Git commit 344524df9ec212f5043ffc32e223b9a5bc07c1f4 by Vlad Zahorodnii. Committed on 21/09/2026 at 12:47. Pushed by vladz into branch 'master'. Add kde_output_device_mode_v2.release This request will be used to cleanup output device mode resources on the compositor side. M +12 -3 src/protocols/kde-output-device-v2.xml https://invent.kde.org/libraries/plasma-wayland-protocols/-/commit/344524df9ec212f5043ffc32e223b9a5bc07c1f4
Git commit bf588d66e8dcfe8ba4d1d81f17d27c6b6ddcd760 by Vlad Zahorodnii. Committed on 24/09/2026 at 11:39. Pushed by vladz into branch 'master'. Revert "wayland: destroy mode resources when the output device resource is released" This reverts commit 12a066c05a457e58a2bbc118abf2347ed73c93dc. This made plasmashell crash. Unfortunately, it looks like we cannot destroy an output device mode resource after sending the removed event because there can be an in-flight output configuration request that reference that mode. M +0 -16 src/wayland/outputdevice_v2.cpp https://invent.kde.org/plasma/kwin/-/commit/bf588d66e8dcfe8ba4d1d81f17d27c6b6ddcd760
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/9989
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/10005
Git commit 978d8ad99ab29c587f1a2e328bf462a09e6566ac by Vlad Zahorodnii. Committed on 30/09/2026 at 15:20. Pushed by vladz into branch 'Plasma/6.8'. Revert "wayland: destroy mode resources when the output device resource is released" This reverts commit 12a066c05a457e58a2bbc118abf2347ed73c93dc. This made plasmashell crash. Unfortunately, it looks like we cannot destroy an output device mode resource after sending the removed event because there can be an in-flight output configuration request that reference that mode. (cherry picked from commit bf588d66e8dcfe8ba4d1d81f17d27c6b6ddcd760) Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> M +0 -16 src/wayland/outputdevice_v2.cpp https://invent.kde.org/plasma/kwin/-/commit/978d8ad99ab29c587f1a2e328bf462a09e6566ac
Git commit 5cdaaca5e57afed15dfa2557747485f63f8c1fbc by Vlad Zahorodnii. Committed on 01/10/2026 at 06:42. Pushed by vladz into branch 'master'. wayland: Implement kde-output-device-v2 v26 M +7 -1 src/wayland/outputdevice_v2.cpp https://invent.kde.org/plasma/kwin/-/commit/5cdaaca5e57afed15dfa2557747485f63f8c1fbc
Git commit b9fce0c13e0e405762d45c5966945c76ad21f334 by Vlad Zahorodnii. Committed on 01/10/2026 at 07:04. Pushed by vladz into branch 'master'. backends/kwayland: Implement kde_output_device_mode_v2 M +1 -1 backends/kwayland/waylandoutputdevice.cpp M +5 -1 backends/kwayland/waylandoutputdevicemode.cpp https://invent.kde.org/plasma/libkscreen/-/commit/b9fce0c13e0e405762d45c5966945c76ad21f334
A possibly relevant merge request was started @ https://invent.kde.org/plasma/libkscreen/-/merge_requests/338
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/10020
Git commit 38590e8e4a19d8222d074d2b7441e277ec7146e4 by Vlad Zahorodnii. Committed on 01/10/2026 at 07:05. Pushed by vladz into branch 'master'. devicenotifications: Add support for kde-output-device-mode-v2 v26 M +6 -2 devicenotifications/devicenotifications.cpp https://invent.kde.org/plasma/plasma-workspace/-/commit/38590e8e4a19d8222d074d2b7441e277ec7146e4
Git commit 706a9d36bc31d37f5b2b5b4ebc1d1e7dfadd8830 by Vlad Zahorodnii. Committed on 01/10/2026 at 07:24. Pushed by vladz into branch 'Plasma/6.8'. backends/kwayland: Implement kde_output_device_mode_v2 (cherry picked from commit b9fce0c13e0e405762d45c5966945c76ad21f334) Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> M +1 -1 backends/kwayland/waylandoutputdevice.cpp M +5 -1 backends/kwayland/waylandoutputdevicemode.cpp https://invent.kde.org/plasma/libkscreen/-/commit/706a9d36bc31d37f5b2b5b4ebc1d1e7dfadd8830
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/7156
Git commit 056b23bb4b567fa5c57eb4efcda39e0343e20d40 by Vlad Zahorodnii. Committed on 01/10/2026 at 07:33. Pushed by vladz into branch 'Plasma/6.8'. devicenotifications: Add support for kde-output-device-mode-v2 v26 (cherry picked from commit d4e4b9bd0768c38d8937e27ff152cb79030fc0c0) Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> M +6 -2 devicenotifications/devicenotifications.cpp https://invent.kde.org/plasma/plasma-workspace/-/commit/056b23bb4b567fa5c57eb4efcda39e0343e20d40
Git commit 9edc801ea67da6875fe874e46a14424c8c624eec by Vlad Zahorodnii. Committed on 01/10/2026 at 08:22. Pushed by vladz into branch 'Plasma/6.8'. wayland: Implement kde-output-device-v2 v26 (cherry picked from commit 5cdaaca5e57afed15dfa2557747485f63f8c1fbc) Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> M +7 -1 src/wayland/outputdevice_v2.cpp https://invent.kde.org/plasma/kwin/-/commit/9edc801ea67da6875fe874e46a14424c8c624eec