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

Large Memory Usage : Manual Way to Cleanup Connection Lists

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.6.0
    • Core: Object Model
    • None
    • VS2015, Windows 7/8/10

    Description

      We've been doing some heap profiling of our QT Application, and we're seeing significant memory cost (25-50%) allocated to :

      QObjectPrivate::Connection
      

      and

       	Qt5Cored.dll!QObject::connect() - Line 2739	C++
       	Qt5Cored.dll!QMetaObjectPrivate::connect() - Line 3283	C++
       	Qt5Cored.dll!QObjectPrivate::addConnection() - Line 383	C++
       	Qt5Cored.dll!QVector<QObjectPrivate::ConnectionList>::resize() - Line 413	C++
       	Qt5Cored.dll!QVector<QObjectPrivate::ConnectionList>::reallocData() - Line 533	C++
       	Qt5Cored.dll!QTypedArrayData<QObjectPrivate::ConnectionList>::allocate() - Line 217	C++
       	Qt5Cored.dll!QArrayData::allocate() - Line 101	C++
      

      I.e. the connection list structs inside the objects.

      After a quick look through the source code, it appears that

      cleanConnectionLists()
      

      is only called in

      void QObjectPrivate::addConnection(int signal, Connection *c)
      

      i.e. it leaves around connection objects until the next time we connect to the object.

      We have many QObjects in a store-based system which aren't being used and when we place them in the store we disconnect all signals/slots (can be up to 30 signals / slots per object) related to them. However these connection objects remain (thankfully the slotObjs are cleaned up on use).

      It appears each connection object costs us 72 bytes, and we can have tens of thousands of objects. For a rough estimate 10000 objects * 72 bytes * 30 connections + unknown cost for connection lists (some of the reallocs are 248 bytes) = ~25mb. If we want to scale past 10000, we'd like to clean up some of these objects that are just lying around.

      Is there a way to explictly clean up these connection objects (and related connection lists) without trying to connect a new (dummy) connection?

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            lmv Luke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes