Breaking the Barrier of Runtime Memory Limitation on Mobile Devices: An example on The Importance of Memory Management in Flash Lite Application Development

memory-management.jpg

Few days ago I posed a question at IndiMad (Indian Adobe Mobile and Devices User Group) whether it is possible to create a standalone  application in Flash Lite (1x/2x) where there will be 20,000 plus data  processed to be displayed in a list. Here is an example profile of the application:

 ———————————————————————————-

Target:

To create a address book type application which will have around 20,
000 entries. Each entry will contain name, email id and a telephone
number.

We can search for a name using any part/full word

The publishing profile:

Flash Lite 1x/2x

Technology:

We may use XML/text file but no major technology other than Flash
Lite,

————————————————————————-

 Well, Jack,  one of my friend from Lebanon was there who few days ago send me a mail requesting a helping hand for such a situation he was in…he needed an application to be developed where more than 20, 000 entries had to be displayed. And when I post about this the answers I received was not specific to it with proposing any positive solution, rather I received comments like there is no point in building such an application.

For example if I am supposed to create a list, we have always the tendency to start by storing the data in separate variables. Most common ways is to store the data in an array . In case of Flash Lite 1.1 we tend to emulate the array using incremental number. For instance   var 0 = “value 1”; var1 = “value2”; …varN = “value(N-1)” etc. And this is where we make mistake. This is because by emulating array we start creating new variables and each variable occupies some runtime memory when application runs. This leads the crash the application when the number of variables is huge as there won’t be any memory left at the run time to process the data. And in case we are storing the huge amount of data in an array (in Flash Lite 2x) , the array object occupies the run time memory and this exceeds 1024 kb (i.e. standard runtime memory available on the device and this amount varies a little from device to device.)

The solution to this is simple but none seemed to use it . And the solution is based on a simple theory of memory and resourse management — “Use less variable leads to get more room in runtime memory”

Using this formula, I tried to solve it and the result was satisfactory. I used two frames loop solution with just two or three variables and this was just like emulating arrays but with a different approach and this worked on Flash Lite 1.1 too !

 I will post an article on this with my sample application source file within few days on my blog.

Advertisements