making an efficient app

MrKim

Well-Known Member
Licensed User
Longtime User
Well I am getting my app working pretty good, now I want to make it efficient and there are a number of things I am not clear on. I am not so much concerned about activities, which are nto used much, but rather the services, one of which runs continuously.

1. When something is "Destroyed" will that take out the Process_Global variables? I am currently using a preference manager to to save and look up things when my service is activated. Can I safeley switch some of those to Global variables and would it be more efficient? It would actually be easier for me as I would like some of these reset when the phone is turned off, as preferences they will be permanently saved.

2. for things like PreferenceManager and MediaPlayer I have dimmed these once as Process Globals in a Module because I read somethng about memory leaks if you don't do this. Is this the most effecient or should I dim them in the Sub that uses them when it is called? Does that slow the operation substantially? What are the tradeoffs?

3. Proccess_Globals can be declared in activites, modules, and services and even though they are global it appears that you must still reference them via the module they are in (ie. othermod.myvariable) if it is not the current module. Is there any advantage to including them in a particular module?

Thanks for your input,

Kim
 
Last edited:

MrKim

Well-Known Member
Licensed User
Longtime User
HOw does one do that? I mean it does what it is supposed to do, but I have noticed that as I have added apps to my phoneit has become sluggish. Can't really pin it down to any one thing.

Also , some of my questions I suppose really boil down to best practices rather than what might or might not improve performance. You can't test for everything, and if I code more or less the way you and most others do then I have less chance of having bugs related to unfound issues.;)

I guess my biggest question is about things like PreferenceManager and MediaPlayer. I am not familiar with objects like these. Is it better to Dim them once globally or dim them within the scope they are used in. I notice the time you quite specifically say should be Dimmed in Process_Globals.

Thanks,
Kim
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
When something is "Destroyed" will that take out the Process_Global variables?
No.
I guess my biggest question is about things like PreferenceManager and MediaPlayer. I am not familiar with objects like these. Is it better to Dim them once globally or dim them within the scope they are used in. I notice the time you quite specifically say should be Dimmed in Process_Globals.
It is better to dim them as process global variables, instead of recreating them each time that the activity is created.
 
Upvote 0
Top