Copy objects -> copy gets slower
-
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? -
Hi,
Which version of Qt ?
On which OS ?
What isnewValue
?Can you provide a minimal compilable example that shows this issue ?
-
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?
-
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?
@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?
-
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. -