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
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
Accepted Solution

Memory use by app

Hi,

 

I downloaded PuTTY and connected to the simulator. I ran "hogs" and noticed that my app was using 32020k of memory. I'm kinda getting worried. My app is just a list view with a bunch of items. When that item is clicked it opens a new qml page. Nothing fancy. I have images that I've put in the assets folder (around 3MB, I can reduce the size of them).

 

I don't have any external connections AT ALL. I see that when I push a new page, the memory increases and pressing "Back" on a page, the memory decreases.

 

All my data is stored in a JSON file. 

I have some html wrapped text to setting bold/italic formatting in labels.

 

Am I just measuring the memory wrong? Is there another way of doing this?

 

Thanks

Developer
Developer
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: Memory use by app

you probably have a lot of QML in  memory...try cleaning tabs, pages etc after use. Pay special attention to childs of Panes (TabbedPane, NavigationPane) especially if the Pane is your main qml file (i.e only cleaned up when app exits).

 

i don't know about 'hogs' but if you use the QNX Momentics IDE, there is a QNX System Information perspective on your top right...it gives a pretty good info about the current state of the heap and stack.

Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Memory use by app

Hi,

 

Thanks for the info. I used the QNX IDE, and see that my app is using 12k for Code, 26M for Data and 148K for Stack. The CPU usage is 621ms. Not quite sure what these numbers mean. I'm using a simulator, does that affect anything? 

 

I have a Navigation Pane inside at Tabbed Pane. This NavPane has a listView inside it. Clicking on a item opens a new page that is stacked on top. Does the page below it need to get destroyed?

 

So when you say 'try cleaning tabs, pages etc', what does that mean? When I click on the "Back" button for a page, does it automatically take care of destroying it?

 

I've also removed some unwanted libraries which reduced the code from 45k to 12k. So thats a good start. However the Data only went from 27M to 26M.

 

- G

 

Developer
Developer
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: Memory use by app

When you push a page on a navpane and then use back, the page is not destroyed/cleaned.

You need to destroy them manually by listebing to the poptransitionended signals of thr nav pane. If not it will only be cleaned when you nav pane destroyed...and in your case, your nav pane is only destroyed when your tabbed pane is destoryed :smileysad:

Hope this is readable...typing on a phone:smileysad:

Your goal should be to make sure your heap doesnt keep increasing when using the app...if it is, then you have a leak.
Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Memory use by app

Hey,

 

Thanks, you've been great help! Slowly piecing this together. Still have some issue however.

So I looked at my code, and realize that I already account for the onPopTransitionEnded field in my qml in the main Navigation pane page.

 

I've noticed that the heap size doesn't increase while using the app. However the Data number increases. Every time I pop the page, the number goes from 30M to 31M and so on. It never goes down.

 

In my listView which is inside the Page (in the Nav Pane), I have the following: 

 

onTriggered: {
                            var chosenItem = dataModel.data(indexPath);
                            countryView = chosenItem;
                            var page = countryPageDefinition.createObject();
                            countryNav.push(page);
                        }

 

 

Right before the NavPane ends, I have the following:

onPopTransitionEnded: {
                page.destroy();
            }

 

However, in this second snippet of code, in the QNX IDE, next to the "page" i see a little "i" which says "Unknown" symbol page. I see this message in other sample app codes as well. I can't place the onPopTransitionEnded anywhere else, as it gives an error. 

 

So either way, the Data number goes up, but should I be worried about that?

 

Thanks,

- G

Developer
Developer
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: Memory use by app

If your heap size doest keep increasing under regular use of your app, then you are good :smileyhappy:

I once tried to make sense out of the data indicator but had no luck with it...if you ever find out what it means, please let me know!!!
Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Memory use by app

Hey,

Thanks man. You've been great help!

-G