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

Adobe AIR Development

Reply
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
Accepted Solution

Monitor memory usage

[ Edited ]

Hi,

 

I was wondering if there was a way to monitor how much memory my app currently uses. I process a lot of images and I don't want to end up with a heavy load app.

 

Thank you

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Monitor memory usage

hey zezke,

 

you can probably get a good feel for the amount of memory in use by Adobe AIR (all instances i believe) by using the System.totalMemory property of the System class which is in the file.System package. Here's more info about this feature:

 

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/System.html#totalMemory

 

hope that helps. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: Monitor memory usage

Thank you for helping me (again).

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Monitor memory usage

hah dont sweat it! if you have anymore questions we'll be more than happy to help you out :smileyhappy:

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
New Contributor
alexbevi
Posts: 8
Registered: ‎12-06-2010
My Device: Not Specified

Re: Monitor memory usage

I know this is marked as solved, but check out http://code.google.com/p/mrdoob/source/browse/trunk/libs/net/hires/debug/Stats.as?r=125

 

I personally use this in all my projects during development.

 

usually I have a component as the last element in my display list that I attach it to

 

<mx:UIComponent id="debug" top="0" left="0" />

so if you use the same example, just add the following to your applicationComplete handler:

 

 debug.addChild(new Stats());

 

 

Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: Monitor memory usage

Nice addition, I will definitely try this. Thank you.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
New Contributor
alexbevi
Posts: 8
Registered: ‎12-06-2010
My Device: Not Specified

Re: Monitor memory usage

I'm sure you'll find this yourself pretty quickly, but I posted a link to the wrong changeset :smileytongue:

 

This is the latest one at the moment: http://code.google.com/p/mrdoob/source/browse/trunk/libs/net/hires/debug/Stats.as?r=236

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Monitor memory usage

[ Edited ]

I'm not sure why you wouldn't just drop the revision as it should then always point to the latest: http://code.google.com/p/mrdoob/source/browse/trunk/libs/net/hires/debug/Stats.as (Oh, and thanks for the link.)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: Monitor memory usage

Are you guys sure this information is accurate? When I load several images in my application the memory usage does not increase.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Monitor memory usage

Memory usage in modern systems isn't straightforward sometimes.  Memory is often allocated from the operating system in large chunks (like megabytes at a time sometimes) which are then managed within an application.  Memory that is "released" is not necessarily returned to the overall pool until an application ends, and so forth.  Memory allocation for embedded assets may be done as the app launches, rather than during what you think are calls to "add" images.

 

If you allocated many megabytes and still see no change, I'd be inclined to agree that some of those calls are not being helpful, though you didn't say exactly what you're doing so it's hard to say.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!