Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138491

Memory leak in QCamera

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.10
    • Multimedia
    • None
    • macOS

    Description

      There is a memory leak in the Apple camera code related to activation. This is only tested FFmpeg backend. The memory leak is easy to reproduce by constructing QCamera objects, activating them and destroying them in rapid succession.

      This has only been tested on macOS.

      Here is a minimal reproducer main.cpp that will construct, activate and destroy a QCamera object every 0.1 seconds.

      #include "mainwindow.h"
      #include <QApplication>
      #include <QTimer>
      #include <QPermission>
      #include <QtMultimedia/QCamera>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();
      
          QTimer myTimer;
          myTimer.setInterval(100);
      
          QObject::connect(
              &myTimer,
              &QTimer::timeout,
              &myTimer,
              []() {
                  QCamera camera;
                  camera.start();
              });
      
          a.requestPermission(
              QCameraPermission{},
              [&](const QPermission &permission) {
                  if (permission.status() != Qt::PermissionStatus::Granted) {
                      a.exit(-1);
                  }
      
              myTimer.start();
          });
      
          return a.exec();
      }
      

      Attached is an image of the memory tracker when running the app through Xcode.

      Attachments

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

        Activity

          People

            qtmultimediateam Qt Multimedia Team
            npskalerud Nils Petter Skålerud
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes