Wednesday, April 25, 2007

Blackberry 7290 application OutOfMemory exception

After testing my application on the simulator, I finally loaded it onto a real blackberry device, model 7290. It was very exciting to see the cute little logo shown up on the screen. Rolling the trackwheel and click, I got an "OutOfMemory" exception thrown right at my face!!! What a bummer.

Both from the Blackberry documentation and the Internet posts, I got the impression that mobile devices have VERY limited memory, just enough to hold some objects and some object references (handlers). So it must be my application using too much memory. I guess there can only be one response from any developer: I need to optimize my code.

So I started optimizing my code, reducing all object creations and references that are not absolutely necessary, sometimes even sacrifice design patterns, best practices and code readability. I guess that is the price you have to pay for efficiency. Did it help? NO.

I was just about to start doing object grouping when I ran over a post on Internet saying it is not your application, it is the JDE version you are using. For the particular device model (7290) and OS version, I need to use Blackberry JDE4.0 versions. The mystery and embarassing OutOfMemory problem was solved just like that.

No comments: