public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/plasma/files/, kde-frameworks/plasma/
Date: Sat,  4 Sep 2021 21:01:21 +0000 (UTC)	[thread overview]
Message-ID: <1630789123.9f7d20409337b1214e7afbb5ca8fa76d8e1c5c9f.asturm@gentoo> (raw)

commit:     9f7d20409337b1214e7afbb5ca8fa76d8e1c5c9f
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sat Sep  4 20:40:03 2021 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sat Sep  4 20:58:43 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9f7d2040

kde-frameworks/plasma: Backport fixes for two longstanding memleaks

See also:
https://invent.kde.org/frameworks/plasma-framework/-/merge_requests/323

Package-Manager: Portage-3.0.22, Repoman-3.0.3
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../files/plasma-5.85.0-fix-svgicon-memleak.patch  | 37 ++++++++++
 .../files/plasma-5.85.0-fix-theme-memleak.patch    | 86 ++++++++++++++++++++++
 kde-frameworks/plasma/plasma-5.85.0-r3.ebuild      |  2 +
 3 files changed, 125 insertions(+)

diff --git a/kde-frameworks/plasma/files/plasma-5.85.0-fix-svgicon-memleak.patch b/kde-frameworks/plasma/files/plasma-5.85.0-fix-svgicon-memleak.patch
new file mode 100644
index 00000000000..89896911d0a
--- /dev/null
+++ b/kde-frameworks/plasma/files/plasma-5.85.0-fix-svgicon-memleak.patch
@@ -0,0 +1,37 @@
+From 73782c8b39d1cc41fef003acca8df75ccdf384e4 Mon Sep 17 00:00:00 2001
+From: Matt Whitlock <kde@mattwhitlock.name>
+Date: Mon, 16 Aug 2021 19:37:28 -0400
+Subject: [PATCH] avoid holding onto old Svg object when changing source of an
+ IconItem
+
+A long-lived IconItem instance can have its source changed many times
+over its lifetime. Because SvgSource parents its internal Plasma::Svg
+instance to the IconItem instance, this means that such Plasma::Svg
+instance was not being destroyed when its responsible SvgSource
+instance is destroyed and indeed would not be destroyed until the
+IconItem instance is eventually destroyed, which could be arbitrarily
+much later. This commit adds an explicit call in the SvgSource
+destructor to delete the Plasma::Svg instance so it does not hang
+around in memory until the IconItem instance is destroyed. This fixes
+one of the major memory "leaks" in plasmashell.
+---
+ src/declarativeimports/core/iconitem.cpp | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp
+index 0db750acd..3f06b8b0e 100644
+--- a/src/declarativeimports/core/iconitem.cpp
++++ b/src/declarativeimports/core/iconitem.cpp
+@@ -196,6 +196,9 @@ public:
+     {
+         if (m_svgIcon) {
+             QObject::disconnect(m_iconItem, nullptr, m_svgIcon, nullptr);
++            // the parent IconItem can outlive this IconItemSource, so delete our Plasma::Svg object
++            // explicitly to avoid leaving unreferenced Plasma::Svg objects parented to the IconItem
++            delete m_svgIcon;
+         }
+     }
+ 
+-- 
+GitLab
+

diff --git a/kde-frameworks/plasma/files/plasma-5.85.0-fix-theme-memleak.patch b/kde-frameworks/plasma/files/plasma-5.85.0-fix-theme-memleak.patch
new file mode 100644
index 00000000000..1d7dc596c20
--- /dev/null
+++ b/kde-frameworks/plasma/files/plasma-5.85.0-fix-theme-memleak.patch
@@ -0,0 +1,86 @@
+From 14b495f933dadace7832fa6cbc809c3abdb7c682 Mon Sep 17 00:00:00 2001
+From: Matt Whitlock <kde@mattwhitlock.name>
+Date: Mon, 28 Jun 2021 18:01:14 -0400
+Subject: [PATCH] don't make duplicate connections to
+ ThemePrivate::onAppExitCleanup
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Plasma::Theme::Theme(…) and Plasma::Theme::setThemeName(…) were
+unconditionally connecting the QCoreApplication::aboutToQuit signal to
+the ThemePrivate::onAppExitCleanup slot, even though the ThemePrivate
+instances are cached and shared across multiple Theme instances. In
+long-running applications that make heavy use of the Svg class (such as
+plasmashell), a single ThemePrivate instance can be reused by huge
+numbers of Theme instances. If the reference count of that ThemePrivate
+instance never reaches zero, then the connections just keep piling up,
+contributing to excessive memory usage. This commit moves the relevant
+connect(…) call so that it only happens in the case that a new
+ThemePrivate instance is constructed. Thus, there will only ever be one
+connection from QCoreApplication::aboutToQuit to
+ThemePrivate::onAppExitCleanup per instance of ThemePrivate.
+---
+ src/plasma/theme.cpp | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp
+index fabf98f4e..f403d393b 100644
+--- a/src/plasma/theme.cpp
++++ b/src/plasma/theme.cpp
+@@ -39,13 +39,13 @@ Theme::Theme(QObject *parent)
+     if (!ThemePrivate::globalTheme) {
+         ThemePrivate::globalTheme = new ThemePrivate;
+         ThemePrivate::globalTheme->settingsChanged(false);
++        if (QCoreApplication::instance()) {
++            connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, ThemePrivate::globalTheme, &ThemePrivate::onAppExitCleanup);
++        }
+     }
+     ThemePrivate::globalTheme->ref.ref();
+     d = ThemePrivate::globalTheme;
+ 
+-    if (QCoreApplication::instance()) {
+-        connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, d, &ThemePrivate::onAppExitCleanup);
+-    }
+     connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged);
+     connect(d, &ThemePrivate::defaultFontChanged, this, &Theme::defaultFontChanged);
+     connect(d, &ThemePrivate::smallestFontChanged, this, &Theme::smallestFontChanged);
+@@ -57,6 +57,9 @@ Theme::Theme(const QString &themeName, QObject *parent)
+     auto &priv = ThemePrivate::themes[themeName];
+     if (!priv) {
+         priv = new ThemePrivate;
++        if (QCoreApplication::instance()) {
++            connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, priv, &ThemePrivate::onAppExitCleanup);
++        }
+     }
+ 
+     priv->ref.ref();
+@@ -68,9 +71,6 @@ Theme::Theme(const QString &themeName, QObject *parent)
+     d->setThemeName(themeName, false, false);
+     d->cacheTheme = useCache;
+     d->fixedName = true;
+-    if (QCoreApplication::instance()) {
+-        connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, d, &ThemePrivate::onAppExitCleanup);
+-    }
+     connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged);
+ }
+ 
+@@ -105,12 +105,12 @@ void Theme::setThemeName(const QString &themeName)
+         auto &priv = ThemePrivate::themes[themeName];
+         if (!priv) {
+             priv = new ThemePrivate;
++            if (QCoreApplication::instance()) {
++                connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, priv, &ThemePrivate::onAppExitCleanup);
++            }
+         }
+         priv->ref.ref();
+         d = priv;
+-        if (QCoreApplication::instance()) {
+-            connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, d, &ThemePrivate::onAppExitCleanup);
+-        }
+         connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged);
+     }
+ 
+-- 
+GitLab
+

diff --git a/kde-frameworks/plasma/plasma-5.85.0-r3.ebuild b/kde-frameworks/plasma/plasma-5.85.0-r3.ebuild
index 433fe380d17..5fcce852061 100644
--- a/kde-frameworks/plasma/plasma-5.85.0-r3.ebuild
+++ b/kde-frameworks/plasma/plasma-5.85.0-r3.ebuild
@@ -64,6 +64,8 @@ PATCHES=(
 	"${FILESDIR}"/${P}-fix-pinned-calendar-dots.patch # KDE-bug 440627
 	"${FILESDIR}"/${P}-fix-cmake.patch # bug 809815
 	"${FILESDIR}"/${P}-fix-ExpandableListItem-overlapping.patch # KDE-bug 428102
+	"${FILESDIR}"/${P}-fix-theme-memleak.patch # in KF-5.86
+	"${FILESDIR}"/${P}-fix-svgicon-memleak.patch # in KF-5.86
 )
 
 src_configure() {


             reply	other threads:[~2021-09-04 21:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04 21:01 Andreas Sturmlechner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-04-22 16:21 [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/plasma/files/, kde-frameworks/plasma/ Andreas Sturmlechner
2022-12-10 10:47 Andreas Sturmlechner
2022-11-16 19:17 Andreas Sturmlechner
2022-10-10  8:15 Andreas Sturmlechner
2022-09-24  8:53 Andreas Sturmlechner
2022-06-29 19:53 Andreas Sturmlechner
2022-05-14 11:33 Andreas Sturmlechner
2022-05-04 20:50 Andreas Sturmlechner
2022-04-09 16:07 Andreas Sturmlechner
2022-01-20 13:26 Andreas Sturmlechner
2021-12-15 11:28 Andreas Sturmlechner
2021-12-08 15:08 Andreas Sturmlechner
2021-09-04 21:01 Andreas Sturmlechner
2020-09-29 12:49 Andreas Sturmlechner
2020-06-23 13:49 Andreas Sturmlechner
2020-06-23 13:49 Andreas Sturmlechner
2020-02-13 21:28 Andreas Sturmlechner
2019-12-31 20:09 Andreas Sturmlechner
2019-03-13 10:18 Andreas Sturmlechner
2017-03-13 21:00 Andreas Sturmlechner
2016-11-17 11:35 Michael Palimaka
2016-02-17 11:13 Michael Palimaka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1630789123.9f7d20409337b1214e7afbb5ca8fa76d8e1c5c9f.asturm@gentoo \
    --to=asturm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox