Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    A memory leak problem about Q_PROPERTY of QList<int>

    QML and Qt Quick
    2
    4
    1613
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      beidaochuan last edited by beidaochuan

      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.

      1 Reply Last reply Reply Quote 0
      • C
        chrisadams last edited by

        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.

        B 1 Reply Last reply Reply Quote 1
        • B
          beidaochuan @chrisadams last edited by

          @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)."?

          1 Reply Last reply Reply Quote 0
          • B
            beidaochuan last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post