[Qt-interest] QPixmap, QMovie and memory consumption

Clemens Eisserer linuxhippy at gmail.com
Wed May 19 21:56:26 CEST 2010


Hi Nikos,

> 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.
Hmm, I don't know QT very well but this could be a bug somewhere, yes.

> 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?

Yes, the memory for the pixmap data is managed by the X-Server, but
that doesn't mean
it can't be freed. In pure Xlib its called XFreePixmap(), I am sure QT
has something equivalent,
calling down to XFreePixmap().

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

"Optimized" means in this context "can be hardware accelerated",
unfourtunatly QT's X11 backend is a bit ugly.
Modern drivers usually store QPixmap's image data directly in the
video memory of your graphic card, which can be *really* fast.
However, as soon as you do something which requires direct pixel
re-read (direct pixel access, drawing something QT can't translate
into XRender commands) performance drops a lot because of all the
overhead copying data back and forth.

So if you don't want to dig into it, using QImage is probably simpler/better.

- Clemens




More information about the Qt-interest-old mailing list