Streamlining Android Apps: Eliminating Code Overhead by Jake Wharton
This talk will focus on techniques that both libraries and applications can implement to ensure their effect is in general without overhead.
It’s a really good stuff to Android developers and those Java developers whether they are doing android or not.
CPU
- Do not nest multi-pass layouts
- Lazily compute complex data when needed
- Cache heavy computational results for re-use
- Consider RenderScript for performance
- Keep work off the main thread
Memory
- Use object pools and caches to reduce churn
- Be mindful of the overhead of enums
- Do not allocate inside the draw path
- Use specialized collections instead of JDK collection when appropriate (SparseArray)
I/O
- Batch Operation with reasonable back-off policies
- Use gzip or binary serialization format
- Cache data offline with TTLs for reloading
- Use JobScheduler API to batch across OS