I Netease blog Original: http://hubingforever.blog.163.com/blog/static/171040579201243071752744/
I. Preface memoryleaktool is a script tool compiled by Robin Hu to monitor memory usage of Android processes. It is short for MlT. Main functions: 1. It is used to test whether one or more processes have memory leaks. 2. It is used to automatically extract an hprof file and convert it to the format recognized by mat for analysis. This function needs to generate the hprof file first in your program code.
Android2.3 PlatformCurrent version: 1001
Android4.03 PlatformCurrent Latest Version: 1011 historical version: 1001 (android4.03 platform) II. runtime platform: Window dependent software 1: Install JDK and add its bin directory to the environment variable path. Dependency Software 2: Install the android-sdk4.0 and add its platform-tools directory to the environment variable path. 3. Configure parameters to decompress the MLT to your computer and use NotePad to open the config. BAT file for parameter configuration. Batch configuration file config. bat is as follows: REM the following VaR is for getprocessstate. batset rawdatadir = rawdataset processname = android. process. acore; COM. android. systemuirem set processshortname = A; B; cset processshortname = set outroot = outset statfileprefix = statrem the following VaR is for gethprof. batset tools = D: \ SDK \ android-sdk4.0 \ toolsset hpinputfiledir =/sdcardset hpinputfile = input. hprofset hproot = hptemp Note 1: rawdatadir is "P S-X "directory of the extracted files NOTE 2: processname needs to count the memory process names. Multiple processes can be counted at the same time. Process names are separated. NOTE 3: processshortname refers to the abbreviated form of the process whose RSS is to be counted. If it is not set or set to null, this program will be automatically generated according to processname. Note 4: outroot counts the directory where the last generated file is stored for the RSS of the process. Note 5: statfileprefix is the prefix of the last generated file for statistics on the RSS of the process. Note 6: toolsis the directory where hprof-conv.exe is located. Note 7: hpinputfiledir is the directory of the hprof file generated on the mobile phone. Note 8: hpinputfiledir indicates the name of the hprof file generated on the mobile phone. 4. Process PSS memory statistics (proportional set size) refers to the physical memory actually used by the process (proportional allocation of memory occupied by the shared library ). Pss indicators are useful for developers. For testers, use RSS indicators. For details about how to collect RSS statistics, refer to the following article. Make sure that your phone is connected to your computer, make sure that debug mode is enabled on your phone, and then double-click runmemorypicker. BAT to bring up the page,
The interval time in the interface indicates a long time to extract the memory information of a process. click the button to start memory statistics. After performing some repeated operations on the phone, if you want to check whether these operations have caused config. whether the process specified in bat has memory leakage. Open the out directory under the MLT Directory, which has generated some memory sampling value files for processes. For example, in the values file, you will see some numerical sequences: nativesize: Numbers, 13232,13232,13232,13232,13133, numbers, 13232,13232,13232,131_dalviksize: 11015,11015, large, small, listen, 11655, listen 55, 11655, listen 55, 11655, listen 55,,, 9559,9559 the first thing we need to care about is totalpss. Copy the numerical sequence in totalpss and use these numerical sequences to generate charts in Excel,
Check whether the function curve is stable at last. If the curve is unstable, memory leakage may occur. In addition, to review frequent memory statistics for a process, delete the old statistical file in the out directory. 5. Process RSS memory statistics RSS (resident set size) indicates the actual physical memory size used by the process (including the memory occupied by the shared library) RSS indicators are useful for testers, it is best for R & D personnel to use the PSS indicator. For details about how to count the process of PSS, refer to the previous article. Make sure that your phone is connected to your computer, make sure that the debug mode is enabled, and then double-click runprocessstatepicker. BAT to bring up the page,
The interval time in the interface indicates a long time to extract the memory information of a process. click the button to start memory statistics. After performing some repeated operations on the phone, if you want to check whether these operations have caused config. whether the process specified in bat has memory leakage. Open the out directory under the MLT Directory, which has generated some memory sampling value files for processes. For example, in the sequence file, you will see numerical sequences: rsssize: Numbers, numbers, numbers 16, numbers 16, numbers 16, numbers 16, numbers 16, numbers 16, numbers 16, numbers 16, 56952,80, 56976, 56688, numbers, 56688, 56688, 56688, 56688, 56688, 56688, 56688, 56688, 56688, 56688, 56688, 56688, large, small, copy the data sequence in rsssize from 56732,56732, 56732, 56732, 56732,56736, 56844,40400, 40392,40392, and use these data sequences to generate charts in Excel,
Check whether the function curve is stable at last. If the curve is unstable, memory leakage may occur. In addition, to review frequent memory statistics for a process, delete the old statistical file in the out directory. 6. Extract the hprof file. For more information, see 《
Android Memory leakage tool (hprof)"