[Qt-interest] QPixmap, QMovie and memory consumption
Nikos Chantziaras
realnc at arcor.de
Thu Apr 29 21:35:17 CEST 2010
I'm using a QMovie to load an MNG animation, and then draw the
individual QMovie::currentPixmap() frames using QPainter::drawPixmap().
However, when deleting the QMovie instance, the memory is not freed.
For example, when the QMovie finishes playing, the application is at
about 200MB RAM consumption. About 180MB of those are attributed to QMovie.
When I use QMovie::currentImage() and draw it with QPainter::drawImage()
instead, then there's no problem. When deleting the QMovie, memory
consumption jumps down to about 20MB again.
What is the problem? The docs suggest that on X11 "a QPixmap is stored
on the server side while a QImage is stored on the client side". Does
that mean that every QPixmap ever created by the application will linger
around forever with no possibility to reclaim the used memory unless the
application quits?
I'd use QImage instead of QPixmap, but according to the docs, "QImage is
designed and optimized for I/O, and for direct pixel access and
manipulation, while QPixmap is designed and optimized for showing images
on screen." Though it doesn't try to explain what "optimized" means
exactly, so I have no idea what I would lose if I switch from pixamps to
images.
More information about the Qt-interest-old
mailing list