Bug 392568 - Memory leak when browsing launcher's menus
Summary: Memory leak when browsing launcher's menus
Status: RESOLVED DUPLICATE of bug 368838
Alias: None
Product: plasmashell
Classification: Plasma
Component: Application Launcher (Kickoff) (show other bugs)
Version: 5.12.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-31 16:42 UTC by Jesse
Modified: 2018-04-19 00:59 UTC (History)
3 users (show)

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


Attachments
plasmashell log (27.53 KB, text/plain)
2018-03-31 16:42 UTC, Jesse
Details
log of: QSG_INFO=1 plasmashell 2>heap.log (72.79 KB, text/x-log)
2018-04-02 20:59 UTC, suse
Details
massif (233.77 KB, text/plain)
2018-04-02 21:02 UTC, suse
Details
massif with some debug symbols (199.67 KB, text/plain)
2018-04-02 21:57 UTC, suse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse 2018-03-31 16:42:33 UTC
Created attachment 111758 [details]
plasmashell log

It seems there's a memory leak in plasma's launchers. It happens both on Application Dashboard and Application Launcher. Steps to reproduce:

1. open KSysGuard and filter plasmashell in the processes.
2. launch Application Launcher and browse the application menus repeatedly, and watch as ram usage increases
3. after a while, close the launcher, open it again, and repeat step 2

This keeps increasing plasmashell's ram usage unstoppably. After a day of work I usually have plasmashell consuming about 1GB ram. Killing plasmashell and starting it again is a workaround.

I'm not sure if this can be related, but I have a nvidia card (GTX 970).

I posted plasmashell journal in the attachment. Please let me know there's another relevant log to post. Also, I recorded a video showing this issue in action: https://youtu.be/9D4TfWE1_vk
Comment 1 suse 2018-03-31 17:31:25 UTC
confirmed.
Every switch into a deeper menue cost some RAM.
Comment 2 David Edmundson 2018-04-02 18:45:16 UTC
Can I have:

output of
QSG_INFO=1 plasmashell

also ideally a log from massif

Please reset bug status when done.
Comment 3 suse 2018-04-02 20:59:28 UTC
Created attachment 111788 [details]
log of: QSG_INFO=1 plasmashell 2>heap.log

here's the log of command:
QSG_INFO=1 plasmashell 2>heap.log
Comment 4 suse 2018-04-02 21:02:36 UTC
Created attachment 111789 [details]
massif

here's the log of command:
export QSG_INFO=1
pkill plasmashell; sleep 1; valgrind --tool=massif  plasmashell

I've made several menu switches which increase RAM usage by at least 10-30 MB.
Comment 5 suse 2018-04-02 21:03:21 UTC
reset bug status to confirmed
Comment 6 suse 2018-04-02 21:57:37 UTC
Created attachment 111790 [details]
massif with some debug symbols
Comment 7 David Edmundson 2018-04-02 22:12:47 UTC
Leaks are in images and we're using the basic render loop - it's the same "slideshow bug" just in a different place

*** This bug has been marked as a duplicate of bug 368838 ***
Comment 8 Jesse 2018-04-03 01:16:07 UTC
It might be related, but I tried the qt declarative patch on that thread and the bug still persists for me.
Comment 9 David Edmundson 2018-04-18 13:18:33 UTC
Oh dear.

Please show me which patch you applied.
Comment 10 Jesse 2018-04-18 18:19:14 UTC
This one:

diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index ca1fb9b..ebd506d 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -305,6 +305,8 @@ void QSGGuiThreadRenderLoop::hide(QQuickWindow *window)
 {
     QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
     cd->fireAboutToStop();
+    if (m_windows.contains(window))
+        m_windows[window].updatePending = false;
 }
 
 void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
@@ -494,7 +496,8 @@ QImage QSGGuiThreadRenderLoop::grab(QQuickWindow *window)
 
 void QSGGuiThreadRenderLoop::maybeUpdate(QQuickWindow *window)
 {
-    if (!m_windows.contains(window))
+    QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
+    if (!cd->isRenderable() || !m_windows.contains(window))
         return;
 
     m_windows[window].updatePending = true;
-- 
2.7.4
Comment 11 David Edmundson 2018-04-18 20:18:02 UTC
That looks like mine.

Can you add debug on: 

lastDirtyWindow around line 395 and tell me if when it's leaking it's always evaluated to false? If so it's the same bug just my patch needs to be more extensive.

If not...we have a different bug
Comment 12 Jesse 2018-04-18 23:23:16 UTC
I tried it, but the debugs in that method are not printed at all. So I think this is a different bug indeed.
Comment 13 David Edmundson 2018-04-19 00:48:51 UTC
If they're not being printed at all, you'd have to be running a different render loop to the one in your debug on line 3.

If absolutely none of your debugs appear the other possibility is that you're not actually running the library you're compiling.
Comment 14 Jesse 2018-04-19 00:59:35 UTC
>If absolutely none of your debugs appear the other possibility is that you're not actually running the library you're compiling.

I checked this by putting a debug message on the instance method, which was printed normally.

> If they're not being printed at all, you'd have to be running a different render loop to the one in your debug on line 3.

I'm not sure what you mean by this. How can I check if a different render loop is running and what does that mean? I'm not familiarized with c++ and qt development, so I might be missing something here.