Skip to content

Image (NumPy array) data not released when closing plot windows (memory leak?) #466

@nanoant

Description

@nanoant

Long story short, pyqtgraph is not releasing NumPy array variables once they are used by some plots.

Run following commands line by line and observe your memory usage (eg. in task manager):

import numpy
import pyqtgraph
a=numpy.ones((128,1024,1024)) #<- 1GB now used by python
del a                         #<- memory released python now is using just few MBs
a=numpy.ones((128,1024,1024)) #<- 1GB now used again by python
pyqtgraph.image(a) # opens a window
pyqtgraph.QtGui.QGuiApplication.exec() # just run Qt event loop, so we can close the window
# now close the plot window
del a #<- python still uses 1GB, even I have just released NumPy array
pyqtgraph.cleanup() #<- no effect, still 1GB used
import gc
gc.collect() #<- absolutely no efffect, still 1GB used

Is there any reason that this memory is not collected and pyqtgraph is keeping references to non-accessible plot objects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions