Bug 501274 - Garbage Collector is not cleaning memory
Summary: Garbage Collector is not cleaning memory
Status: RESOLVED UPSTREAM
Alias: None
Product: plasmashell
Classification: Plasma
Component: Wallpaper images (show other bugs)
Version: 6.3.2
Platform: Other Linux
: NOR crash
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-09 20:07 UTC by Arthur Lobo
Modified: 2025-03-10 22:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
test.qml (1.31 KB, text/x-qml)
2025-03-10 11:21 UTC, Harald Sitter
Details
Small Video with nothing (8.96 KB, video/mp4)
2025-03-10 22:30 UTC, Arthur Lobo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Lobo 2025-03-09 20:07:19 UTC
SUMMARY

I use an extension to reproduce videos as wallpapers on my desktop. Actually I am contributing to the project on GitHub here: https://github.com/luisbocanegra/plasma-smart-video-wallpaper-reborn and I made a preview for the videos to see how the videos will be treated in some circumstances. I did a pull request (https://github.com/luisbocanegra/plasma-smart-video-wallpaper-reborn/pull/94) but we found a memory bug that can crash some weak computers.

The RAM usage still increasing after close the media component and event closing the wallpaper settings window, the .destroy() method and garbage collector calls don't have any effect. The only way to reduce the RAM usage is restarting the plasmashell service. I tried other things like Load videos using webviews, using dynamic Video components bug nothing resolves this.

STEPS TO REPRODUCE
1. Clone https://github.com/ArthurLobopro/plasma-smart-video-wallpaper-reborn/tree/feat-real-time-video-show
2. Build and Install using install.sh
3. Choose the extension as Wallpaper and add some videos
4. Click in Show videos list and after Click on settings button for each video added
5. See the RAM usage raising
6. Close the settings window 

OBSERVED RESULT

The RAM usage keeps high, even closing the window

EXPECTED RESULT

The RAM usage should fall because the videos should be destroyed after closing the window

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Big Linux based on Manjaro
KDE Plasma Version: 6.3.2
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2

ADDITIONAL INFORMATION

If I change the wallpaper to an image and after I change again to the plugin the RAM usage raises the same way, something aren't stopping and cleaning unused media players
Comment 1 Harald Sitter 2025-03-09 21:28:10 UTC
We don't maintain QtMultimedia, you'll want to talk to Qt I guess.
Comment 2 Harald Sitter 2025-03-10 11:21:22 UTC
Created attachment 179260 [details]
test.qml

For what it's worth I've had a quick look and I think there is no actual leak. What happens is that qtffmpeg doesn't fully de-initialize itself when you destroy the Video item. Specifically it holds on to its internal engine until a new media is set. As well as some global statics that only get cleared on app shutdown.

https://codebrowser.dev/qt6/qtmultimedia/src/plugins/multimedia/ffmpeg/qffmpegmediaplayer.cpp.html#188

Depending on the video in question that would be more or less memory it uses, but it shouldn't keep growing forever. And indeed a simple test program I have attached doesn't, it rises for a bit and eventually stays within the same range.
Comment 3 Arthur Lobo 2025-03-10 22:30:10 UTC
Created attachment 179275 [details]
Small Video with nothing

I did a test with this video file with nothing. The file size is about to 4kb and for each time I opened the Dialog rendering it the RAM usage raises 20Mb to 40Mb for each time and keeping raising as I open and close the Dialog.