Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
leonidas61
Posts: 9
Registered: ‎09-12-2013
My Device: Z10
My Carrier: BG Globul

QmlDocument and memory freeing

Hello,

 

I use QmlDocument to create page and use it from C++. I do it in follow fashion:

 

voidMWMPage::createPage(QString pageName)

{

    mwmPage = 0;

    QmlDocument *qml = QmlDocument::create(pageName).parent(this);

    if (!qml->hasErrors())

    {

        mwmPage = qml->createRootObject<Page>();

    }

}

 

When corresponding page is popped, I delete it:

 

voidMWMApplication::smileysurprised:nPopTransitionEnded(bb::cascades::Page *page)

{

    delete page;

    .........

}

 

But it seems memory used by this page is not freed, so if w go through the pages long time, memory concumption increases. It seems we have some cache for pages which is not being freed.

 

According documentation,

 

A note regarding ownership of the objects associated with the QmlDocument object. By default the QmlDocument object is owned by the Application instance and will have the lifespan of the application. If the user wants to handle the lifespan the QObject::setParent method can be used to transfer the ownership. If the QmlDocument instance is only used for creating a single instance of the root object this root object can be set as a parent of theQmlDocument instance so the latter will be deleted when the node instance is deleted.

 

 

Does it mean that I have to set page as parent of QmlDocument? And how to do it correctly?

Please use plain text.
New Contributor
leonidas61
Posts: 9
Registered: ‎09-12-2013
My Device: Z10
My Carrier: BG Globul

Re: QmlDocument and memory freeing

I tried to add

 

        qml->setParent(mwmPage);

 

but after deletion of mwmPage memory actually was not freed

Please use plain text.
Developer
BBSJdev
Posts: 5,986
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: QmlDocument and memory freeing

It's more likely to be some custom control within your Page that is not releasing memory, use the Momentic tools to look at each page destroy and track it down.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
New Contributor
leonidas61
Posts: 9
Registered: ‎09-12-2013
My Device: Z10
My Carrier: BG Globul

Re: QmlDocument and memory freeing

What do you mean under 'custom control'? 

 

Yes, I have ListVews there with ArrayDataModels. And it seems they don't release memory.

 

I don't have controls, completely defined in C++.

 

It seems it is problem, described here:

 

http://supportforums.blackberry.com/t5/Native-Development/QmlDocument-NavigationPane-Qml-C-and-memor...

 

 

Please use plain text.