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
Developer
nicklas
Posts: 150
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha

QmlDocument, NavigationPane, Qml/C++ and memory leaks ?

Hi,

 

Several questions...

 

In all BlackBerry samples, we can read :

 

QmlDocument *qml = QmlDocument::create("asset:///file.qml");

But do we have to delete the qml object ?

 

// 1st solution
QmlDocument *qml = QmlDocument::create("asset:///file.qml");
mContainer = qml->createRootObject<Container>();
qml->setParent(mContainer);

// 2nd solution
QmlDocument *qml = QmlDocument::create("asset:///file.qml");
mContainer = qml->createRootObject<Container>();
delete qml;

 

At last, I create a cascades page from C++ ; then I push my page on a NavigationPane

 

QmlDocument *qml = QmlDocument::create("asset:///file.qml");
mPage = qml->createRootObject<Page>();
qml->setParent(mPage);
mNavigationPane->push(mPage);

From QML back button, I pop the page... but it seems that I have memory leaks :smileysad:

 

To destroy page, I have try from QML and C++ :

 

void App::onPopTransitionEnded(bb::cascades::Page *page) {
// C++ code
delete page
}

onPopTransitionEnded: {
// Qml code
page.destroy();

To do some memory tests, I use the IDE tools and I print the memory info usage from :

 

bb::MemoryInfo memoryInfo;
qDebug() << "Memory = " << memoryInfo.memoryUsedByCurrentProcess()

In any cases, from IDE or my memory print, it seems that my application leaks :smileysad:


And my code doesn't none memory allocation !!!

 

Nicolas

 

Please use plain text.
Developer
nicklas
Posts: 150
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha

Re: QmlDocument, NavigationPane, Qml/C++ and memory leaks ?

At last, I can look the same behavior with Cascades Cook sample.

 

I open the cascades cook sample, I open the first item "Introduction" ; then I repeat (open / close)... and I see the allocations increase (but not free)

 

Nicolas

 

Please use plain text.
Contributor
tipul07
Posts: 11
Registered: ‎10-28-2012
My Device: Z10

Re: QmlDocument, NavigationPane, Qml/C++ and memory leaks ?

Hi there,

 

The method which you use to see if an app is "leaking" is not good. I'm totally a rookie regarding BB development, but it depends very much on how OS manages memeory. So to be quick, apps might just flag memory as garbage, then there is a garbage collector which would release that memory.

I would suggest using a debugging tool (not sure if there's a special debuggin tool which also monitors memory for an app). In my linux development I used kgdb, a front-end for gdb debugging tool. Anyway there are lots of tools there which would monitor apps...

 

Regards,

Andy

Please use plain text.