Today I learned…

… that the ~QX11PixmapData(): QPixmap objects must be destroyed before the QApplication object, otherwise the native pixmap object will be leaked. warning most KDE applications display when exiting is actually false.

The X server will cleanup any opened resources, including pixmaps, automatically when the client exits. This is much like how the kernel automatically closes files and memory allocations when an application exits.

(The QPixmaps in question are the ones cached by KIconLoader as best as I can tell. They are cleaned up, just not before QApplication’s destructor runs.)

5 thoughts on “Today I learned…

  1. Björn Ruberg Identicon Björn Ruberg

    Might this be the reason why my X-servers uses more and more RAM over time until I restart it?

  2. Will Stephenson Identicon Will Stephenson

    @Björn: No, read the article again. It says that the leak warning from QApps that are terminating is incorrect. Your X server may be using more and more RAM over time because apps that are still running are allocating more and more pixmaps, but it is good at cleaning up after apps that no longer run.

  3. Richard Moore Identicon Richard Moore

    @TGM what do you mean? This is X11 specific as evidenced by the class QX11PixmapData, it should work on any X server though if that’s what you’re asking.

Comments are closed.