Android may have a memory leak where the summary:
1. Querying the database without closing cursors
2. When building adapter, no cached Convertview is used
3.Bitmap object is not used when calling the Recycle () method to free memory
4. Releasing a reference to an object
5. Singleton mode refers to context, if using actvitiy-context, can cause memory leak,
can use Getapplicationcontext ()); or Getapplication () instead.
Reference Documentation:
A?n?d?r?o? i?d?????
Http://wenku.baidu.com/view/3dbfb0a1b0717fd5360cdc47.html
Ways to analyze memory leaks:
1. Analyze memory leaks using the mat
2. Use Procrank to record memory movements
Use Procrank to keep track of the use of a process which we often rely on with scripts. This allows you to see the memory changes for a certain period of time.
If you create a file: trackmem.sh chmod 775 trackmem.sh
The contents are as follows:
#!/bin/bash
While true; Do
ADB Shell Procrank | grep "Com.example.studymemroyleak"
Sleep 1
Done
Run the script:
./trackmem.sh
The purpose of this script is to let the system output the memory usage of the specified process once every 1 seconds, mainly to observe the USS data, can directly output data to the XLS table
./trackmem.sh > Data.xls
Then generate a line chart (choose to draw only lines), and note the units (K) of the numbers. When you create a chart, you select the data, and then you insert the chart.