- Enums often require more than twice as much memory as static constants. You should strictly avoid using enums on Android.
- Every class in Java (including anonymous inner classes) uses about 500 bytes of code. and every class instance has 12-16 bytes of RAM overhead.
- Putting a single entry into a HashMap requires the allocation of an additional entry object that takes 32 bytes
- Use optimized container from android framework like SparseArray, SparseBooleanArray, and LongSparseArray. generic HashMap use can be quite memory inefficient because it needs a separate entry object for every mapping so use SparseArray.
- Release memory as memory becomes tight
- onTrimMemory() callback of Activity help you finding way to release resource. Callbacks like TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL etc gives you way to release unused resource which eventually help improving performance of your app
- Load views on demand using ViewStub read about ViewStub
- Use multiple process in a single application. Name your background services as separate process like
<service android:name=”.PlaybackService” android:process=”:background” />