Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,738,971 Members 44,154 Now Online
XDA Developers Android and Mobile Development Forum

Optimizing memory usage

Tip us?
 
LinuxForce
Old
(Last edited by LinuxForce; 4th July 2014 at 09:15 PM.)
#1  
Junior Member - OP
Thanks Meter 0
Posts: 6
Join Date: Mar 2014
Default Optimizing memory usage

Hi !

I'm developing me first "real" (some minor projects before) app for android. Right now i'm trying to optimize the memory usage, regarding to this I have a question. I hope someone can help me.

I've implemented a foreground service, which also updates some UI-elements via a static reference of the MainActivity.

My question is, what happens if the UI is not visible (i.e. MainActivity is destroyed) ? Are these calls ignored ? Are they using memory ?

Thanks in advance!
 
surlac
Old
#2  
Junior Member
Thanks Meter 1
Posts: 15
Join Date: Feb 2012
You shouldn't keep reference objects with short lifecycle from an object with long lifecycle, unless you carefully manage these references.
To answer your question: UI-elements will be kept in memory till ClassLoader will be destroyed or the references will be nullified.
The Following User Says Thank You to surlac For This Useful Post: [ Click to Expand ]
 
bbish937
Old
#3  
Junior Member
Thanks Meter 0
Posts: 11
Join Date: Jul 2014
Quote:
Originally Posted by LinuxForce View Post
Hi !

I'm developing me first "real" (some minor projects before) app for android. Right now i'm trying to optimize the memory usage, regarding to this I have a question. I hope someone can help me.

I've implemented a foreground service, which also updates some UI-elements via a static reference of the MainActivity.

My question is, what happens if the UI is not visible (i.e. MainActivity is destroyed) ? Are these calls ignored ? Are they using memory ?

Thanks in advance!
Once the activity is destroyed there should be no more running resources, ie. memory usage. If you want to stop other UI-elements such as lingering toasts or dialogs, you can overwrite the onDestroy method to do so.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes