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

Java Development

Reply
Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

battery usage / background threads

I recently made a few changes in my app and appear to have caused a somewhat dramatic change in power consumption / reduction in battery life. For testing purposes I created a new background network thread - it is not doing more work than my network thread, but its using the new network api and has some small tweaks.  and since im testing, im running both at the same time. but since they do very little work i wouldnt expect it to be a huge issue.  Also i've added a in-screen loading/wait message with an animated gif. its basically always running on the app screen, its just made visible/hidden when appropriate.  could that animation thread be causing problems?  

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: battery usage / background threads

Have you seen this?

 

http://supportforums.blackberry.com/t5/Java-Development/BlackBerry-features-and-their-impact-on-batt...

 

This would suggest that the network activity that you are doing has the most signidicant impact.  However I think the animation is causing the issue.  I would test this, by simply not running it.  Let us know how you get on.

Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: battery usage / background threads

Yes i saw that thread, but the focus seems to be on how GPS kills your battery (which im not using). There are only a very few network connections (estimate 20-30 a day?) doing minimal work.  the thread(s) are always running in the background, waiting for a request.  i was hoping to add a pull/checkin since im not sure i can do push through my BES, but if my network connections are what are causing the problem now, adding many more wont be an option.

im going to try disabling the timertask on the loader screen that increments the frame count for the animated gif and see if it makes a difference. sucks b/c i'll have to wait all day to see if it makes a difference :smileyhappy: unless there are any other methods of determining battery drain?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: battery usage / background threads

similar to gps the network connections have an idle mode where less battery is consumed. every time you do any networking the network "wakes up" and consumes additional battery.

regular tasks should be done not too often if it can be avoided.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: battery usage / background threads

I know there have been people looking for task managers/CPU/memory usage monitors ... is there anything like that? I havent seen anything in the API to show cpu or memory usage for an app.  how do other developers test the impact of certain threads or new additional functions that they are adding to their apps?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: battery usage / background threads

you can use profiling in the jde debugger maybe. the APIs are not telling you very much.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: battery usage / background threads

so i had no idea that eclipse had profiling abilities (i should pay more attention to find out about these things ...  and apparently stop using so many hashtables). unfortunately im not sure either the eclipse or jde  profiles/debuggers are going to help figure out my battery problems.

I changed my loader screen so that my show/hide loader methods start and stop an animation thread instead of it always running. But that didnt seem to make any difference in battery life.  My only other main change i can think of was changing to the ConnectionFactory from the standard pre-5.0 method of making a network connection, but no idea why that would cause a problem. it must be some other random change i made somewhere. ill keep looking.

Developer
yog123
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: battery usage / background threads

Hi Guys ,

 

I am facing somewhat same issue.

 

 

I have an app I wrote that connects to my server throughout the day. The connection stays open the entire time in case the server needs to send an data to my blackberry. 
The connection is socket connection of which InputStream is always- open in continuous while loop. 
I find that the battery drains very quickly with the connection open.
In 10-12 hours the battery is about 25% charged. Without the connection open the battery probably lasts 5 times longer.

Is it normal for there to be such a huge increase in power consumption? How does an applications like Google Talk or twitter  use so little power? Does it listen for a connection rather than keep one open? 
If anybody has some info please share, or am i doing something wrong???
Any help is appreciated.
JDE 4.6.0
Testing Device-- 8900 with OS 4.6.1.250

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: battery usage / background threads

use push, not pull. it's blackberry, after all

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
StevenKader
Posts: 645
Registered: ‎02-03-2010
My Device: Z10 LE

Re: battery usage / background threads

Here are some of my experiences from actual expirements that I have done :

 

1)  Network activity is worse than phone calls in draining battery.

 

2)  Staying constantly connected will be  a battery killer.  If you need to wait for alerts that can come at anytime the best and only non-battery killing way would be to use PUSH, which is free.

 

3) Checking 30 times a day isn't terrible but if you could get away with once an hour that should be fine.

 

4) To test your app for battery drainage I think of it in % drain per hour.  Normal usage runs around 5% per hour.  If run with your app for an hour or 2 you can see how much the battery was used and if it is much more than 5% you may have an issue.

 

Hope this helps.


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing