Background
Although the Android device is getting more and more high, however, due to the mechanism of the Android system (mostly the main thread of the app will not actually exit but in the background resident memory)
, so that after installing too many apps in the phone, the memory is heavily occupied, and finally the memory for the system and application operations is reduced.
Therefore, in the development process, we need to pay special attention to memory optimization and release.
Summary of the General
A note
1 Java Four ways to reference, soft, weak reference ...
2 reduce unnecessary global variables, especially the context
3 Closing the Dispose resource object
For sqliteopenhelper,sqlitedatabase,cursor, files, I/O operations should be remembered to show off.
4 Avoid creating unnecessary objects
5 Cache
6 layout is faster than XML with Java code; View optimization
7 using a thread pool to handle complex, time-consuming operations
Two notation
8 Avoid using floating-point numbers, in Android devices, floating-point numbers are twice times slower than integers
9 using the static final modifier for constants
10 Avoid internal getters/setters, direct field access is about 3 times times faster than calling getter access
11 static methods instead of virtual methods
12 Avoid using enumerations, poor performance
13 replacing serialization serialization with Precelable
14 data compression, transmission
......
In the ps:android system, the memory allocated by each individual app is an integer multiple of 8, up to a maximum of 32MB.
Google launches Android performance optimization model
Http://www.oschina.net/news/60157/android-performance-patterns
Android Memory Optimizer