QtQuick, multiple string concatenation and embedded devices
I've written an application for Windows XP/Vista/7 and Windows CE 6.0 (ARM) with Qt 4.7.3
using QtQuick for the configurable UI and with some extra QML elements written in C++.
The desktop version had no problems, but the embedded version had a very weird
when assigning a concatenated string expression to a string property
of a custom QML element written in C++.
myObject.myStringproperty = "aaaa" + anotherObject.anotherStringProperty + "bbbb"
produced a memory leak, while
myObject.myStringproperty = ["aaaa", anotherObject.anotherStringProperty, "bbbb"].join()
works without problems.
My guess is that the temporary strings allocated by the sequence of consecutive concatenations
are not deallocated properly or cause some weird fragmentation in the heap, while the join()
does string concatenation precalculating the resulting string size (i.e. no temporary strings)
or does deallocation of temporary strings in a different way.
Does somebody else noticed the same problem on other Windows CE devices or on other platforms ?
Does it leak indefinitely or does the garbage collector eventually reclaim it? If not then I would file a bug for this if I were you.
@ZapB: on my Windows CE 6 device it seems it leaks indefinitely.
I’ve asked here in the forum because I wanted to check if somebody else had problems like this.
I’m still trying to understand what’s exactly happening because it may be caused by a circular chain of dependencies or by something wrong in my customized windows CE image.
When the property in my custom QML Element is modified there is data transmitted to a remote device (using a separate thread to decouple the I/O operations from the main thread) and when the answer from the remote device is received the same element emits some events on the qml side.
On Windows 7 it seems there are no problems, but there memory management is different.
Before filing a bug report I want to be sure it isn’t something i did with my custom C++ QML elements and if there is a way to easily replicate it with a simple example on other device/OS.
I understand. Probably the best bet is to try to make a very minimal example (circa 200 lines of code) that reproduces the problem then post it here. Then we can try it too. It sounds like you have already investigated to quite an extent though. Still such examples are very useful to attach to the bug reports to help the devs resolve them more quickly.