Bug 387630

Summary: Discover Plasma Addons Possible Memory Leak
Product: Discover Reporter: r.doherty
Component: KNewStuff BackendAssignee: Aleix Pol <aleixpol>
Status: RESOLVED FIXED    
Severity: major CC: bugseforuns, DanielHalens, leinir, nate, northivanastan, trialism, zapaolo
Priority: NOR    
Version: 5.11.4   
Target Milestone: ---   
Platform: Neon Packages   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=395669
Latest Commit: Version Fixed In: 5.12

Description r.doherty 2017-12-05 23:49:59 UTC
Discover Menu's all working as normal besides "Plasma Addons". Once entered the side menu will attempt to load a list of the addons, as this happens (and fails) the program will gradually consume more and more RAM until the entirety of the systems RAM is consumed causing a litany of errors that required a hard shut down.
Comment 1 Ivan S 2017-12-10 23:02:56 UTC
(In reply to r.doherty from comment #0)
> Discover Menu's all working as normal besides "Plasma Addons". Once entered
> the side menu will attempt to load a list of the addons, as this happens
> (and fails) the program will gradually consume more and more RAM until the
> entirety of the systems RAM is consumed causing a litany of errors that
> required a hard shut down.
Run in the command prompt: 
plasma-discover >> discover_out.txt
and post the output. I can't seem to replicate this same bug.
Comment 2 Ivan S 2017-12-10 23:17:25 UTC
(In reply to Ivan S from comment #1)
> (In reply to r.doherty from comment #0)
> > Discover Menu's all working as normal besides "Plasma Addons". Once entered
> > the side menu will attempt to load a list of the addons, as this happens
> > (and fails) the program will gradually consume more and more RAM until the
> > entirety of the systems RAM is consumed causing a litany of errors that
> > required a hard shut down.
> Run in the command prompt: 
> plasma-discover >> discover_out.txt
> and post the output. I can't seem to replicate this same bug.
Actually I can confirm this. The leak is very slow, however, and no useful output is generated from plasma-discover >> discover-out.txt. When clicking Plasma Addons, the following appears in the log:
stream took really long "KNS-search-plasma-themes.knsrc"
stream took really long "KNS-search-wallpaper.knsrc"
stream took really long "KNS-search-cgcgtk3.knsrc"
stream took really long "KNS-search-xcursor.knsrc"
stream took really long "KNS-search-cgctheme.knsrc"
stream took really long "KNS-search-icons.knsrc"
stream took really long "AggregatedResultsStream"
Not sure if this is a memory leak though. It may just be Plasma trying to load the entirety of the OpenDesktop database into RAM - databases like that can be as big as 1tb. Discover does not seem to work under valgrind, which makes leak detection hard.
Comment 3 Nate Graham 2018-01-14 05:21:16 UTC
*** Bug 388911 has been marked as a duplicate of this bug. ***
Comment 4 Daniel Halens 2018-01-16 14:40:37 UTC
(In reply to Ivan S from comment #2)
> (In reply to Ivan S from comment #1)
> > (In reply to r.doherty from comment #0)
> > > Discover Menu's all working as normal besides "Plasma Addons". Once entered
> > > the side menu will attempt to load a list of the addons, as this happens
> > > (and fails) the program will gradually consume more and more RAM until the
> > > entirety of the systems RAM is consumed causing a litany of errors that
> > > required a hard shut down.
> > Run in the command prompt: 
> > plasma-discover >> discover_out.txt
> > and post the output. I can't seem to replicate this same bug.
> Actually I can confirm this. The leak is very slow, however, and no useful
> output is generated from plasma-discover >> discover-out.txt. When clicking
> Plasma Addons, the following appears in the log:
> stream took really long "KNS-search-plasma-themes.knsrc"
> stream took really long "KNS-search-wallpaper.knsrc"
> stream took really long "KNS-search-cgcgtk3.knsrc"
> stream took really long "KNS-search-xcursor.knsrc"
> stream took really long "KNS-search-cgctheme.knsrc"
> stream took really long "KNS-search-icons.knsrc"
> stream took really long "AggregatedResultsStream"
> Not sure if this is a memory leak though. It may just be Plasma trying to
> load the entirety of the OpenDesktop database into RAM - databases like that
> can be as big as 1tb. Discover does not seem to work under valgrind, which
> makes leak detection hard.
I can confirm the bug on 5.11.5
On my system, the leak is very fast (about 1GB / 10 secs!)
I found out that clicking quickly on any section under Plasma Addons will avoid the bug until going back and entering again.
Comment 5 Paolo Zamponi 2018-01-17 12:48:43 UTC
Hi all, I can confirm this, too. If I follow the process via kSysGuard I see it takes all the memory, and probably it's killed when swap partition is full.

If I run in the command prompt: plasma-discover >> discover_out.txt, this file is empty, but in the console I can see this:

$ plasma-discover >> discover_out.txt
invalid kns backend! "/etc/xdg/servicemenu.knsrc" because: "Config group not found! Check your KNS3 installation."
invalid kns backend! "/etc/xdg/ksysguard.knsrc" because: "Config group not found! Check your KNS3 installation."
Discarding invalid backend "servicemenu.knsrc"
Discarding invalid backend "ksysguard.knsrc"
setting currentApplicationBackend PackageKitBackend(0x564000d05bd0)
qml: Kirigami.Label is deprecated. Use QtQuickControls2.Label instead
qml: Kirigami.Label is deprecated. Use QtQuickControls2.Label instead
stream took really long "KNS-search-plasma-themes.knsrc"
stream took really long "KNS-search-xcursor.knsrc"
stream took really long "KNS-search-icons.knsrc"
stream took really long "KNS-search-cgctheme.knsrc"
stream took really long "KNS-search-wallpaper.knsrc"
stream took really long "KNS-search-cgcgtk3.knsrc"
stream took really long "AggregatedResultsStream"
Ucciso (Italian for 'killed')

About KNS3 installation I don't know, I'm on Opensuse Tumbleweed and a package called "knewstuff" is already installed... when the system seems to work fine I notice an unnormal (I think) swap space in use... I'm not a technician, but it seems everything can't return to a complete normality...
Comment 6 Aleix Pol 2018-01-29 17:59:25 UTC
Git commit df12760c58e185949cd753802a16d75d7a436400 by Aleix Pol.
Committed on 29/01/2018 at 17:32.
Pushed by apol into branch 'Plasma/5.12'.

Cap the amount of KNS requests we do per query

There are a lot of wallpapers...

M  +7    -1    libdiscover/backends/KNSBackend/KNSBackend.cpp
M  +1    -0    libdiscover/backends/KNSBackend/KNSBackend.h

https://commits.kde.org/discover/df12760c58e185949cd753802a16d75d7a436400