Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-3031

Memory leak in QByteArray

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 6.8.2
    • PySide
    • Linux, PySide6 2.8.2, Python 3.12.9
    • Linux/X11

    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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            tomas.314 Tomas Bouda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes