Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 13:03, 3 June 2009 by tanjaluodes (Talk | contribs)

Code Optimization - Java ME

From Wiki
Jump to: navigation, search

Since mobile phones have low heap memory, restrictions on jar sizes supported, and slow CPU's, optimizations can be employed to improve your applications performance. Consider your usage of memory, application size, and CPU overhead.

Here is a compilation of code optimization techniques which may be quite helpful to reduce jar size and memory usage.

  1. Use an obfuscator like the free Proguard or Retroguard. They can remove unused code and perform other optimizations to decrease MIDlet size (JAR file size).
  2. Use minimum number of classes, even a mostly-empty class uses space.
  3. Avoid unnecessary object creation.
  4. Reuse objects when possible.
  5. For saving memory, explicitly set unused object to null.
  6. Beware of calling garbage collection, calling system.gc to free memory may cause slowdowns because in certain phones it is a blocking statement.
  7. Use only minimum images in the application to save space.
  8. If not using an obfuscator
        1. All the variable, method & class name should be small
        2. Remove any unwanted code
        3. The package structure should be as minimum as possible, if possible avoid packages
53 page views in the last 30 days.