[PySide] QPixmap memory leak
Hannu Tatein
htatein123 at gmail.com
Thu Jan 14 22:57:38 CET 2016
Hi Pyside Experts,
I have written a GUI/Image viewer using Pyside. It works perfectly for my
purpose except that as I browse through the images, the memory consumption
of computer increases.
The code snippet that is responsible for the memory leak is this:
self.pixmap = QtGui.QPixmap(str(self.nb) + "_" + str(self.fig_type) +
".jpeg")
self.pixmap = self.pixmap.scaled(1000, 4000,
QtCore.Qt.KeepAspectRatio,
mode=QtCore.Qt.
SmoothTransformation)
self.lbl.setPixmap(self.pixmap)
if not self.added_lbl:
self.layoutImW.addWidget(self.lbl)
self.added_lbl = True
self.lbl.setGeometry(500, 500, self.pixmap.width(),
self.pixmap.height())
Actually it is the first statement of the code snippet that is the root of
all the evil. If instead of the variables : 'self.nb' and 'self.fig_type',
I try to load the same image, I don't face the problem.
Is there any way to avoid the memory leak? I tried QtGui.QPixmap.deref()
before the first image, it does seem to work.
If any part of the code is not clear, please let me know and I will get
back to you immediately.
Thanks you very much,
Hannu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160114/e96fd31e/attachment.html>
More information about the PySide
mailing list