Memory Leakage using PySide

76 views
Skip to first unread message

Nils Gran

unread,
Oct 26, 2015, 10:57:20 AM10/26/15
to pyqtgraph
Hi,

I'm experiencing a memory leak using PySide with the following configuration:
OS: Win7
python==3.4
pyqtgraph==0.9.10
pyside==1.2.2

This seems to be a problem only when using PySide (I've also tested on PyQt4 without any issues).

Is this a known bug, any workarounds available?

from PySide.QtGui import QApplication, QMainWindow
from PySide.QtCore import QTimer

import sys
import pyqtgraph as pg
from collections import deque
from random import random
pg.setConfigOptions(antialias=True)


class MainWindow(QMainWindow):

    def __init__(self):
        super(MainWindow, self).__init__()
        self.setGeometry(300, 300, 700, 400)
        self.setWindowTitle('PySide Memory Leak')

        self.graph = pg.GraphicsLayoutWidget()
        self.plt = self.graph.addPlot(title="PySide Memory Leak Example")

        self.x = deque([0], maxlen=100)
        self.y = deque([random()], maxlen=100)

        self.timer = QTimer()
        self.timer.timeout.connect(self.plot)
        self.timer.start(50)

        self.setCentralWidget(self.graph)
        self.show()

    def plot(self):
        self.x.append(self.x[-1] + 1)
        self.y.append(random())
        self.plt.plot(self.x,
                      self.y,
                      clear=True,
                      pen='y',
                      symbolBrush='y',
                      symbolPen='w',
                      symbolSize=5,
                      symbol='o')


def main():
    QApplication.setStyle("plastique")
    app = QApplication(sys.argv)
    ex = MainWindow()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

Reply all
Reply to author
Forward
0 new messages