Mobile performance summary

We summarise our approach to performance optimisation and some of the experimental findings below:

Compare algorithms

  • Talk to colleagues and pick the best algorithm; having the best possible algorithm is the most effective way to optimise performance.

Simple architecture

  • Keep your architecture simple and to the point without extra layers of method calls or objects for artificial abstraction. Mobile front end code does not last for ever, so over-engineering and excessive abstraction into multiple classes will slow you down compared to simple use of variables.

Use worker threads

  • Use a worker thread architecture as your baseline for networking, storage and background calculations.

  • Add a game loop thread and disposable media threads to this as needed.

Manage memory with WeakReference caching

  • Avoid memory problems by always accessing image data in memory using a WeakReference Cache.

  • Create a type of virtual memory by duplicating the WeakReference cache contents in Flash memory (Record Management System) so that you can quickly recover items which are no longer available in RAM.

Use final and similar micro-optimisations by habit as you code

  • Know the rules of micro-optimisation for memory performance, logic and calculations. Include those as you develop, but trust Proguard to add the finishing touches.

  • Help Proguard by making everything possible final or static final. Avoid static variables in high performance loops as they are slower than instance variables.

Profile your MIDlet toward the end of a project

  • Profile your application in an emulator.

  • Also test the actual run-time of critical code sections on the phone using System.currentTimeMillis() to see and carefully measure the effects of your code changes.

Last updated 9 October 2013

Back to top