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. [SOLVED] Memory release when apps switched to background
QtWS25 Last Chance

[SOLVED] Memory release when apps switched to background

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.1k Views
  • 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 Offline
    H Offline
    hoanghua
    wrote on last edited by
    #1

    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
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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
      0
      • H Offline
        H Offline
        hoanghua
        wrote on last edited by
        #3

        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
        0
        • M Offline
          M Offline
          mbrasser
          wrote on last edited by
          #4

          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
          0
          • H Offline
            H Offline
            hoanghua
            wrote on last edited by
            #5

            Thanks Michael, works like charm ;-)

            Just wonder why this useful tip is not documented anywhere.

            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