Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to deal with Leaks Pixmap in Qt?
Forum Updated to NodeBB v4.3 + New Features

How to deal with Leaks Pixmap in Qt?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 788 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leonardoMB
    wrote on last edited by leonardoMB
    #1

    Here is the heob top part of the stack:

    1: malloc in 
      2: QArrayData::allocate(unsigned long long, unsigned long long, unsigned long long, QFlags<QArrayData::AllocationOption>) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Core.dll
      3: QString::QString(int, Qt::Initialization) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Core.dll
      4: QPixmap::load(QString const&, char const*, QFlags<Qt::ImageConversionFlag>) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
      5: C:/mylibrary.dll
    

    I basically pass a QPixmap("image.png") to some classes and functions, all by reference, and I use a QIcon::setPixmap in the end. I don't see any reason to existence of leakage here, any Idea?

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #5

      The 'leak' in QPixmapCache is a false positive - it's a cache and (mYBE9 not cleared on exit so the leak checker will complain but it's not a memleak in the classic way. Add it to the ignore list of your leak checker.
      The leak in your first post is imo also a false positive. You can check it when you allocate and deallocate a pixmap several thousand times in a loop.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      L 1 Reply Last reply
      2
      • L leonardoMB

        Here is the heob top part of the stack:

        1: malloc in 
          2: QArrayData::allocate(unsigned long long, unsigned long long, unsigned long long, QFlags<QArrayData::AllocationOption>) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Core.dll
          3: QString::QString(int, Qt::Initialization) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Core.dll
          4: QPixmap::load(QString const&, char const*, QFlags<Qt::ImageConversionFlag>) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
          5: C:/mylibrary.dll
        

        I basically pass a QPixmap("image.png") to some classes and functions, all by reference, and I use a QIcon::setPixmap in the end. I don't see any reason to existence of leakage here, any Idea?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @leonardoMB
        The "leak" code you show has nothing to do with QPixmap, it's just to do with the QString handling of "image.png".

        I doubt there is any leakage going on, but I don't know enough about what heob reports to argue.

        L 1 Reply Last reply
        1
        • JonBJ JonB

          @leonardoMB
          The "leak" code you show has nothing to do with QPixmap, it's just to do with the QString handling of "image.png".

          I doubt there is any leakage going on, but I don't know enough about what heob reports to argue.

          L Offline
          L Offline
          leonardoMB
          wrote on last edited by
          #3

          @JonB
          And in things like this?:

          1: malloc in 
            2: operator new(unsigned long long) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/libstdc++-6.dll
            3: QPixmapCache::Key::operator=(QPixmapCache::Key const&) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
            4: QPixmapCache::remove(QString const&) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
            5: QPixmap::load(QString const&, char const*, QFlags<Qt::ImageConversionFlag>) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
          
          JonBJ 1 Reply Last reply
          0
          • L leonardoMB

            @JonB
            And in things like this?:

            1: malloc in 
              2: operator new(unsigned long long) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/libstdc++-6.dll
              3: QPixmapCache::Key::operator=(QPixmapCache::Key const&) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
              4: QPixmapCache::remove(QString const&) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
              5: QPixmap::load(QString const&, char const*, QFlags<Qt::ImageConversionFlag>) in C:/Qt/Qt5.15.2/5.15.2/mingw81_64/bin/Qt5Gui.dll
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @leonardoMB
            Not sure that's on a QString! :)
            It seems so fundamental I would have thought any leaks like this would have been spotted.
            But I leave other experts to comment further.

            1 Reply Last reply
            1
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #5

              The 'leak' in QPixmapCache is a false positive - it's a cache and (mYBE9 not cleared on exit so the leak checker will complain but it's not a memleak in the classic way. Add it to the ignore list of your leak checker.
              The leak in your first post is imo also a false positive. You can check it when you allocate and deallocate a pixmap several thousand times in a loop.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              L 1 Reply Last reply
              2
              • Christian EhrlicherC Christian Ehrlicher

                The 'leak' in QPixmapCache is a false positive - it's a cache and (mYBE9 not cleared on exit so the leak checker will complain but it's not a memleak in the classic way. Add it to the ignore list of your leak checker.
                The leak in your first post is imo also a false positive. You can check it when you allocate and deallocate a pixmap several thousand times in a loop.

                L Offline
                L Offline
                leonardoMB
                wrote on last edited by leonardoMB
                #6

                @Christian-Ehrlicher Thanks for the answer, This is the first time I use a memory profile and i'm recent to Qt too. Would you recommend something to analyze if something is a false positive? I ask this because I got "leaks" in a lot of metacalls and I couldn't judge properly anything

                1 Reply Last reply
                0
                • Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  From my pov you can ignore everything your tool finds inside Qt - it's very unlikely.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved