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

Memory leak in BLE discovery

    XMLWordPrintable

Details

    • Windows
    • 37a9d533c5 (qt/qtconnectivity/dev) e8240ffe2a (qt/qtconnectivity/6.4) a9910088b2 (qt/qtconnectivity/6.3) a9910088b2 (qt/tqtc-qtconnectivity/6.3) e8240ffe2a (qt/tqtc-qtconnectivity/6.4) 37a9d533c5 (qt/tqtc-qtconnectivity/dev)
    • Foundation PM Staging

    Description

      Repeatedly scanning with QBluetoothDeviceDiscoveryAgent on Windows causes RAM usage to rise continuously (as reported by Resource Monitor). In Debug mode, the app consumes <8MB at startup, rising to 50MB by the 50th scan.

      The same leak was not observed on Ubuntu 22.04 (using top or `pmap -x`).

       

      Test Code

      #include <QBluetoothDeviceDiscoveryAgent>
      #include <QCoreApplication>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
      
          QBluetoothDeviceDiscoveryAgent discoveryAgent;
          discoveryAgent.setLowEnergyDiscoveryTimeout(5000);
      
          auto doScan = [&]{
              static int i = 0;
              qDebug() << "Starting scan; Iteration" << ++i;
              discoveryAgent.start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
          };
      
          QObject::connect(&discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, &app, [&]
          {
              qDebug() << "Found" << discoveryAgent.discoveredDevices().count() << "devices";
              doScan();
          });
      
          doScan();
          return app.exec();
      }
      

       

      Notes

      Attachments

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

        Activity

          People

            ivan.solovev Ivan Solovev
            skoh-qt Sze Howe Koh
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes