This is a difficult to answer question. There is no general answer to this question, it depends on your priorities. For some apps(chess programs) it is the efficiency, for some apps(gallery app) it is the memory usage that is more important. However, more often than not, neither of these could be a bottleneck. In such cases, you should choose the cleanest and easiest to maintain way.
However in my experience, most of the time it is the memory that cause the bottleneck(if there is one at all) on Android. On StackOverflow
, everyday I see some posts about OutOfMemory
errors and I rarely see a my app is running too slow
post.
Here are some specific tips that come to my mind:
1) Call
bitmap.recycle();
whenever the bitmap
is not needed. This could release the memory earlier.
2)
Try to avoid file access as much as possible. Using a SQLite db can help you achieve that in a more efficient way.
3)
Don't leak memory. Use memory management tools that come with eclipse to track those leaks.
4)
Hand big files in chunks, and small files without chunks!
5)
Check this video on "android memory management". It gives plenty of useful information.
Also there is similar discussion here: Memory efficiency vs Processor efficiency (note that it is not specifically for android)