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
New Contributor
Posts: 4
Registered: ‎02-06-2011
My Device: Not Specified

Running Applications and the LOW_MEMORY Event

Will the QNXApplicationEvent.LOW_MEMORY only trigger for apps in the background, or will it also be dispatched to active applications?

 

If it's the latter, let's say your app is in the form of a game. How do you respond to the event if they are in the middle of it?

 

Do you make a dialog, like "Warning! Your device is running low on memory. Please end other processes in order to continue this game." ?

 

Or do you wait it out, hoping that other running applications will free up memory, solving the problem?

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Running Applications and the LOW_MEMORY Event

Good question.

 

It should get triggered if you are active or in the background.

 

You should save any state that you have.

 

The OS will shut down apps that have not been used for awhile in hopes to free up memory.

 

I would not put up an alert, but some indication (passive) that memory might be running low in the app bar or other part of the application might be a good idea, but I would wait until you get an actual PB to see if this will be a problem or not.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Running Applications and the LOW_MEMORY Event

hey,

 

according to the Development Guide:

 

( http://docs.blackberry.com/en/developers/deliverables/23959/Responding_to_low_memory_1430556_11.jsp )

 

it mainly deals with applications in the background that are in danger of being closed to free up memory. so you should save the state of your application if the memory starts to decrease and the trigger is received by your app. the event will also be received by apps not in the background and are currently being used.

 

if you get a low memory event when the user is using your app, the safest bet is to save the current state of your app and let the user know whats happening that way they dont get too angry when something crashes (whether its your app or other apps running). people like to know whats going on rather than be surprised. so if you let them know that you were notified of a problem, then they'll appreciate it more im sure.

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
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Running Applications and the LOW_MEMORY Event

I still would not put up an alert in response to a low memory event.  Depending on how the OS dispatches these events, the user could get a bunch of alerts, especially if more than one open app does this.  Passive notification (after saving state) at most.  Flashing icon somewhere that they can click on (e.g. scull and cross bones), to see what is going on -- then show an alert.

 

$0.02

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Running Applications and the LOW_MEMORY Event

@jtegen: i agree. it'd be annoying to have to close every pop up about low memory. if we were to notify its best if is unintrusive and subtle enough to have the user know it happened and not interfere with normal usage of the playbook.

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
Highlighted
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Running Applications and the LOW_MEMORY Event

Keep in mind that it could be from your app or some other app.  If it's your game app that's consuming too much memory, probably from a memory leak because it's buggy, then the user might not notice anything for a while, but all the inactive apps would be getting terminated quietly out of view.

 

Your game may keep running, until it's all by itself but sucking up all of system memory.  Depending on memory conditions (how much the terminated apps were using), your app may get additional LOW_MEMORY notifications, as the background apps are terminated and memory is freed but then your game keeps sucking it away.

 

At the very absolute least, consider showing a notification when you get two consecutive notifications while your app is still the only one that's active.  (That is, reset the count every time you are reactivated.)  I'm guessing a bit, but I believe that would most likely be indicating that a background app was killed, but memory kept getting drained.  It may not be your app doing it, but the user really should be alerted in some fashion.

 

You can also attempt to monitor how much memory your own app is consuming using the data from flash.system.System.  You could measure memory during testing (but probably not with debug mode enabled) and integrate some value above that into your code as a "max expected usage", if that's possible with your app.  Then, if you get a LOW_MEMORY event and your memory check tells you you're above that threshold, there's a chance you've got a leak and should let the user know there may be a problem.  Of course, far better to test fully and be sure there isn't one before you release.

 

Most of the above is speculation, random pondering, and untested advice, so consider it worth up to the limit of how much you paid for it. ;-)  Writing it gave me some ideas for my own use though...


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!