Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QtQuick, multiple string concatenation and embedded devices
Forum Updated to NodeBB v4.3 + New Features

QtQuick, multiple string concatenation and embedded devices

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 6.5k 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.
  • L Offline
    L Offline
    L.MCH
    wrote on last edited by
    #1

    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
    memory leak.

    It happened in javascript code (in the QML side of the application)
    when assigning a concatenated string expression to a string property
    of a custom QML element written in C++.

    I.e.

    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 ?

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      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.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • L Offline
        L Offline
        L.MCH
        wrote on last edited by
        #3

        @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.

        At first I looked into my C++ code thinking the problem was there, then looking at the javascript code written by the developer responsible of the UI customization I noticed the leaks happened when there were lots of string concatenations before setting the custom property, using a simple string copy (i.e. myProperty = “a single string”) there were no problems and when i tried using join() (to check if the leaking got better or worse) the leaks vanished.
        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.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          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.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          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