08-19-2011 04:07 PM
08-22-2011 07:57 AM
I have made a few apps that has these problems too. Unfortunately it is worse in 2.1.1 for me.
A solution that works for me is not to have any local variables in my javascript methods. If it is used only once fine, but if it used all the time, use global variables instead. I thought it could have something with "garbage collection" to do and it drastically solved 95% of my memory issues.
08-22-2011 08:22 AM
08-22-2011 08:46 AM
genvej wrote:
I have made a few apps that has these problems too. Unfortunately it is worse in 2.1.1 for me.
A solution that works for me is not to have any local variables in my javascript methods. If it is used only once fine, but if it used all the time, use global variables instead. I thought it could have something with "garbage collection" to do and it drastically solved 95% of my memory issues.
Now that is really interesting and has me puzzled....
The local variables that you moved out to global variables, were they pointing to blackberry.* objects?
08-22-2011 09:08 AM - edited 08-22-2011 09:12 AM
___________________________________
_________________________________________
You dare say my apps are simple!? ![]()
![]()
It is quite easy doable in even mid complex apps. It is definately not considered good practice in programming in general, but I have yet to see any mobile apps where this would be a difficult task. I am not saying you should globalize all your variables, but you could try it for the some of the most used methods (methods in loops etc).
Im not saying that it works. It was something i tried (in 3 different apps) with great success
08-22-2011 09:11 AM
Those variables points to both Blackberry objects and simpler types as well. I never did it in more than one tempi, so I cant say wheether my success was due to Blackberry variables only-
08-22-2011 09:13 AM
08-22-2011 10:04 AM
08-22-2011 10:08 AM
08-22-2011 10:33 AM
pseudo-code is more like this
function timer(){
while (true){
doWork();
sleep(30000);
}
}
var list;
var number;
var gpsObject;
function doWork(){
list=getList();
number=10;
gpsObject=getGPS("11,2222","12,11111");
}
I moved variable declaration out of the function scope. This approach worked for me.