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. Copy objects -> copy gets slower
Forum Updated to NodeBB v4.3 + New Features

Copy objects -> copy gets slower

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 62 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MHermann
    wrote last edited by
    #1

    Hi all,
    I have following situation:

    QtObject {
        id: blub
        property var obj: ({}) 
    }
    

    This property is changed regularly.
    The new value is received by a signal and then copied.
    But it gets slower with each copy.
    For example, the first copy takes 180ms, after a few times it takes 600ms.

    I tried different ways to copy it:

    1) blub.obj = newValue
    2) blub.obj = JSON.parse(JSON.stringify(newValue))
    3) blub.obj = Object.assign({}, newValue);
    

    What am I doing wrong?
    How can I prevent it from slowing down with every copy?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      Which version of Qt ?
      On which OS ?
      What is newValue ?

      Can you provide a minimal compilable example that shows this issue ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        MHermann
        wrote last edited by
        #3

        Hi,

        I am using Qt5.12.7.
        I am developing the app on Linux and then it gets cross-compiled to run Raspbian.
        newValue is a big json-object.

        At the moment I don't have a minimal example.

        Has anyone ever had the problem that copying values ​​becomes slower over time?

        JonBJ 1 Reply Last reply
        0
        • M MHermann

          Hi,

          I am using Qt5.12.7.
          I am developing the app on Linux and then it gets cross-compiled to run Raspbian.
          newValue is a big json-object.

          At the moment I don't have a minimal example.

          Has anyone ever had the problem that copying values ​​becomes slower over time?

          JonBJ Online
          JonBJ Online
          JonB
          wrote last edited by
          #4

          @MHermann
          Others will know more than I. Just some thoughts.

          • Just how big is "big"? MBs? GBs?
          • I can imagine/guess that after the initial setting of the property it will destroy its current value before replacing it with a new one. That could add (quite?) some time to copies after the first time?
          • Is this specifically a JSON issue? If you create a property which is, say, a huge string do you see the same slow down over time?
          • Are you able to test with the last Qt 5.15 instead of your 5.12?
          1 Reply Last reply
          0
          • M Offline
            M Offline
            MHermann
            wrote last edited by
            #5

            Thanks for your answer.
            In meanwhile I was able to solve this problem.
            I think it was related to the singleton.
            The QtObject blub was in a singleton-qml-module.
            Now I moved this QtObject to the main-qml-module.
            Now the copy is much faster and it does not get slower.

            1 Reply Last reply
            0
            • M MHermann has marked this topic as solved

            • Login

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