Search code examples
memoryqt4qmlblackberry-10

Does destroy() method deallocate the memory of page?


I am using destroy() method as follows:

onPopTransitionEnded: {
       page.destroy();
   }

my question is does this destroy() method deallocates all the memmory occupied by the page and its child?

Page{
content:
Container{
ImageView{
//properties
}
}
}

will the destroy() method destroy every thing in content property of page?

The reason behind asking this question is, when I observe the memory using QNX Memory analyzer. I couldn't see the decrease in memory uses. I also observed the memory usage of app in device monitor, as I navigate to next page it shows increment in memory uses but when page is destroyed onPopTransitionEnded the memory uses didn't come down.

Please let me know if there is any tool that may help me to observe the memory uses. or any documentation that may help me.:Helpsmilie:


Solution

  • First of all - yes, "detroy()" will also destroy all implicit and explicit children of your Page, but not instantly:

    Note that it is safe to call destroy() on an object within that object. Objects are not destroyed the instant destroy() is called, but are cleaned up sometime between the end of that script block and the next frame (unless you specified a non-zero delay).

    You can use Component.onDestroyed() attached signal to ensure that object was deleted.

    Seems that memory can be freed little bit later when threshold memory value will be achieved. You can try to test it via creating and deleting a lot of object and obesrving memory usage.