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

Web and WebWorks Development

Reply
Regular Contributor
Saeger
Posts: 83
Registered: ‎04-29-2011
My Device: 9300 Curve

Re: Device memory is Low issue for an WebWork app

I know what you mean Tim... It's hard to identify some problems..

You (or your team) should give a try to my application and follow the steps that i told above.. The problem will deffinely occour.

The app itself isn't so good looking but i hope you identify the problem!
Márcio Saeger - Software Engineer, Softwell Solutions
Please use plain text.
Regular Contributor
genvej
Posts: 58
Registered: ‎01-19-2011
My Device: 9800

Re: Device memory is Low issue for an WebWork app

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.

Please use plain text.
Regular Contributor
Saeger
Posts: 83
Registered: ‎04-29-2011
My Device: 9300 Curve

Re: Device memory is Low issue for an WebWork app

Good to hear, but, in my case it's a little difficult because my applications isn't so simple...
Márcio Saeger - Software Engineer, Softwell Solutions
Please use plain text.
Retired
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Device memory is Low issue for an WebWork app


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?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Regular Contributor
genvej
Posts: 58
Registered: ‎01-19-2011
My Device: 9800

Re: Device memory is Low issue for an WebWork app

[ Edited ]

___________________________________

Good to hear, but, in my case it's a little difficult because my applications isn't so simple... 

_________________________________________

 

You dare say my apps are simple!? :Boat:

 

:smileywink:

 

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

Please use plain text.
Regular Contributor
genvej
Posts: 58
Registered: ‎01-19-2011
My Device: 9800

Re: Device memory is Low issue for an WebWork app

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-

Please use plain text.
Regular Contributor
genvej
Posts: 58
Registered: ‎01-19-2011
My Device: 9800

Re: Device memory is Low issue for an WebWork app

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-
....
Please use plain text.
Retired
ababut
Posts: 46
Registered: ‎07-08-2010
My Device: Superberry

Re: Device memory is Low issue for an WebWork app

Genvej, that is very interesting, can you post a quick code snippet to illustrate better which variables you make global?

Are you doing something like this pseudo-code?

var a = blackberry.app.myFunction;

function doStuff() {
a();
}
-------------------------------------------------------------------------------------------------
Useful resources, food for the brain:
Web(Works) KB - http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/tkb-p/browser_dev%40tkb
Please use plain text.
Regular Contributor
Saeger
Posts: 83
Registered: ‎04-29-2011
My Device: 9300 Curve

Re: Device memory is Low issue for an WebWork app

genvej,

I'm talking about 8k lines in one .JS file.
I have around 200 files in the application...
:smileytongue:
Márcio Saeger - Software Engineer, Softwell Solutions
Please use plain text.
Regular Contributor
genvej
Posts: 58
Registered: ‎01-19-2011
My Device: 9800

Re: Device memory is Low issue for an WebWork app

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.

 

 

Please use plain text.