Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. A memory leak problem about Q_PROPERTY of QList<int>
QtWS25 Last Chance

A memory leak problem about Q_PROPERTY of QList<int>

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.8k Views
  • 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 Offline
    B Offline
    beidaochuan
    wrote on last edited by beidaochuan
    #1

    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
    0
    • C Offline
      C Offline
      chrisadams
      wrote on last edited by
      #2

      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
      1
      • C chrisadams

        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 Offline
        B Offline
        beidaochuan
        wrote on last edited by
        #3

        @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
        0
        • B Offline
          B Offline
          beidaochuan
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved