Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] Memory release when apps switched to background

    QML and Qt Quick
    2
    5
    1842
    Loading More Posts
    • 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.
    • H
      hoanghua last edited by

      Hi,

      I'm writing an application on Meego platform. When the application is switched to background, I want to release as much as memory as possible. What I've been doing so far.

      • Listening for switch-to-background event
      • Clear pagestack

      However, seems that it doesn't help much (usage memory is still ranged from 50-70MB). Can you suggest any thing that I can do to achieve the target? Our application has lots of images, could it be a reason for using lot of memory? I know the images are cached, but I assumed that it should be freed when the application switched to background.

      1 Reply Last reply Reply Quote 0
      • M
        mbrasser last edited by

        Hi,

        You could try manually triggering garbage collection via gc(). Hopefully future versions of QML/Creator will include some nice tools for analyzing memory usage.

        Regards,
        Michael

        1 Reply Last reply Reply Quote 0
        • H
          hoanghua last edited by

          Hi,

          Sorry for asking a silly question. On which object/class should I invoke gc()? Trying to google for the answer; but can't find though.

          Thanks,

          1 Reply Last reply Reply Quote 0
          • M
            mbrasser last edited by

            Hi,

            gc() is a function on the global object, so you should be able to call it from anywhere. e.g.

            @
            Component.onCompleted: gc()
            ...
            MouseArea {
            onClicked: gc()
            }
            ...
            function doSomething() {
            gc()
            }
            ...
            @

            Regards,
            Michael

            1 Reply Last reply Reply Quote 0
            • H
              hoanghua last edited by

              Thanks Michael, works like charm ;-)

              Just wonder why this useful tip is not documented anywhere.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post