How to deal with Leaks Pixmap in Qt?
-
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.dllI 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?
-
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. -
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.dllI 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?
@leonardoMB
The "leak" code you show has nothing to do withQPixmap, it's just to do with theQStringhandling of"image.png".I doubt there is any leakage going on, but I don't know enough about what heob reports to argue.
-
@leonardoMB
The "leak" code you show has nothing to do withQPixmap, it's just to do with theQStringhandling of"image.png".I doubt there is any leakage going on, but I don't know enough about what heob reports to argue.
@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 -
@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@leonardoMB
Not sure that's on aQString! :)
It seems so fundamental I would have thought any leaks like this would have been spotted.
But I leave other experts to comment further. -
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. -
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.@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
-
From my pov you can ignore everything your tool finds inside Qt - it's very unlikely.