In fact, I suspect that there is always a memory leak when calling QPixmap's
constructor, but that in some cases it is not noticed because some form of
optimization is preventing QPixmap construction when it is superfluous.

Note that the following code in the timer callback causes a memory blow-up,
but simply switching the pxmp assignment statements, and leaving everything
else as-is, results in no memory blow-up.

        img = QtGui.QImage('tiger.png')
        fd, pathname = tempfile.mkstemp('.bmp')
        os.close(fd)
        img.save(pathname, "BMP")
        pxmp = QtGui.QPixmap(pathname)
#        pxmp = QtGui.QPixmap('tiger.png')
        os.remove(pathname)
        self.lbl.setPixmap(pxmp)

Ranen


On Fri, Mar 18, 2011 at 3:45 PM, Ranen Ghosh <[email protected]> wrote:

> Hi, I am noticing a memory leak with PySide's QPixmap.fromImage static
> method.
> Here is a small example program to demonstrate it:
> http://pastebin.com/VmKncUFY
>
> For the first 30 seconds or so, everything seems fine.  At that point, my
> Xorg process's memory usage starts to shoot up at about 20M per second.
>
> The following info may be helpful:
>
> If I use the QPixmap's constructor with the filename as an argument, rather
> than using the static QPixmap.fromImage method, I don't observe the memory
> issue.
>
> If I don't call self.lbl.setPixmap(pxmp) , I don't observe the memory
> issue.
>
> If I double the timer delay, it takes roughly twice as long for the memory
> spike to happen.
>
> If I replace PySide with PyQt4 in the import statements, I do not observe
> this memory issue.
>
> Ranen
>
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to