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

QObject::disconnect call does not free memory

    XMLWordPrintable

Details

    • Windows

    Description

      There is increase in memory usage due to QObject::connect and QObject::disconnect calls when the application creates objects at an interval of 50 ms in a separate thread. In MainWindow, the previously created object's destroyed() signal is disconnected from the slot and the pointer to the newly created object is copied to the local member variable. Then the newly created object's destroyed signal is connected to a slot. Each object will create a buffer of 1000 bytes internally. The pointer to object will be stored in a list which is a member variable of the object creation thread. The memory consumption increases faster with connect/disconnect calls than without.

      Means to reproduce:

      1. build and run the attached example project with Qt version 5.15.3
      2. Press Start button.
      3. Wait for timer to stop
      4. Check the memory usage of the application.
      Then
      5. Close the application and rerun it
      6. Check "Use Connect" check box
      7. Press Start Button
      8. Wait for timer to stop
      9. Check the memory usage of the application.
      10. Compare the memory usage of these two runs.

      There is an option to do longer test runs included instead of the 5 minute one.

      Attachments

        1. main.cpp
          1 kB
        2. main2.cpp
          1 kB
        3. main3.cpp
          1 kB
        4. memwatch.ps1
          0.6 kB
        5. qtbug91696.zip
          5 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            agolubev Andrei Golubev
            foxxx Tuukka Kettunen
            Maurice Kalinowski Maurice Kalinowski
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes