self.win = pg.GraphicsWindow()
self.win.setWindowTitle(self.title)
self.p = self.win.addPlot()
self.curve = self.p.plot(self.Data1, pen='k')
Many thanks for reading!
--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/e26192b4-7729-4ddc-8891-444fa944d883%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import pyqtgraph as pg
from PyQt4.QtGui import *
import FirstGUI_ui
class MainWindowGUI(QMainWindow, FirstGUI_ui.Ui_MainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
self.Trend2.clicked.connect(lambda: self.trendGen())
def trendGen(self):
self.Plot1 = MyPlot()
self.Plot1.show()
class MyPlot(pg.PlotWidget):
def closeEvent(self, ev):
self.plotItem.clear()
self.plotItem = None
ev.accept()
print 'Closed!'
self = None
if __name__ == '__main__':
app = QApplication([])
myGUI = MainWindowGUI()
myGUI.show()
app.exec_()
Probably the easiest thing to do is just manually clear the plot when the window is closed, by intercepting or overriding its closeEvent (http://doc.qt.io/qt-4.8/qwidget.html#closeEvent).Ideally though, after you close the window all references to it would disappear and python would release any items displayed in the plot widget. There are many different reasons the widget or its items might still have references to it, though. I added the pyqtgraph.debug.ObjTracker class specifically to help track down leaked references; you can read the docstrings for that class to get an idea of how to use it.
On Sun, Aug 21, 2016 at 11:51 AM, <pytho...@gmail.com> wrote:
Hi All,
My QApplication has a button (on the main window) which, when clicked, launches a pyqtgraph Plot. The code below shows how the plot is generated in a class.self.win = pg.GraphicsWindow()
self.win.setWindowTitle(self.title)
self.p = self.win.addPlot()
self.curve = self.p.plot(self.Data1, pen='k')
One of the things I have noticed is that when I close the plot window in my application, the memory is not released. So for example, before the button is pressed, the Application takes around 20Mb. Once the plot is launched by clicking the button, this increases to 25Mb. But when I close the plot (by clicking on the x in the top right corner), the Application memory footprint stays at 25Mb. Is there any way to release this 5Mb of memory when the plot is closed (note that I have the line 'self.curve.clear()' so there is no leak while the plot is being updated in real-time).
Many thanks for reading!
--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.