A memory leak problem about Q_PROPERTY of QList<int>



  • Hi,
    I meet a problem seems memory leak when using Q_PROPERTY of QList<int>.
    There are some codes below.

    Q_PROPERTY(QList<int> data READ data NOTIFY dataChanged)
    

    I use data[index](index: 0~~10000) in some qml files, and the dataChanged signal is emitted on 200ms.
    The problem is increasing memory consumption, which have trend like 90M→100M→95M→120M→103M. But if I stop emitting dataChanged signal, memory consumption will not increase and be stable.
    what`s wrong with it? Please help me.
    Thanks.



  • Is memory usage increasing in an unbounded fashion? From the numbers you are posting, it appears not - since usage dropped from 120M to 103M etc. What you are probably seeing is memory usage caused by JavaScript references being held to copies of data (retrieved as QVariant(QList<int>) via QObject::property() accessor). When the reference count drops to zero, the JS reference will be moved to the part of the (managed, JavaScript) heap which then gets cleaned up on gc().

    Until the garbage collector runs, that memory will not be truly freed.

    If you're accessing it a lot, you will be seeing a lot of fragmentation due to many small allocations.

    See also http://doc.qt.io/qt-5/qtquick-performance.html#sequence-tips for more information.

    Cheers,
    Chris.



  • @chrisadams Thanks for your reply. But I still do not known how to resolve this problem since dataChanged signal will be emitted on 200ms no stopping. That means memory usage will be increasing for all of the time since "by JavaScript references being held to copies of data (retrieved as QVariant(QList<int>) via QObject::property() accessor)."?



  • The problem just happened While I use Qt 5.5.0.(no problem with Qt 5.4.1)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.