Details
Description
Hello,
I've encountered a subtle yet persistent memory leak through pyqtgraph application.
In essense, it is caused during construction of QPainterPath using combination of QByteArray and numpy.ndarray's buffer interface. Going to the core, the following code reproduces the bug using just memoryview and QByteArray.
import psutil from PySide6 import QtCore proc = psutil.Process() rss0 = proc.memory_info().rss for cnt in range(300_010): if cnt % 10_000 == 0: rss = proc.memory_info().rss print(f'{cnt}: {(rss - rss0)/1048576:.1f} MB') backstore = QtCore.QByteArray() backstore.resize(8192) memoryview(backstore)
The problem was successfully reproduced on Linux and MacOc, but possibly not on Windows. Affected version seems to be 6.7.3 where the memleak occured first.
There's a discussion at pyqtgraph about the problem with further details.
https://github.com/pyqtgraph/pyqtgraph/issues/3265#issuecomment-2689480190