Skip to content

Fix two memory "leaks"

Matt Whitlock requested to merge mwhitlock/plasma-framework:memory-leaks into master
  • don't make duplicate connections to ThemePrivate::onAppExitCleanup

    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.

  • 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.

Merge request reports