[SOLVED] Memory release when apps switched to background



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



  • 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



  • 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,



  • 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



  • Thanks Michael, works like charm ;-)

    Just wonder why this useful tip is not documented anywhere.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.