Skip to content

cokesprite/memory-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Memory Analysis and Comparison Tool

1. Concept
----------

Memory Analysis and Comparison Tool is implemented with Python to process original memory logs like
meminfo, procrank, kmemleak and others.

- Memory Analysis (mmparse.py): it is used to parse memory log files and generate a memory analysis
- Memory Comparison (brdiff.py): it is used to compare two copies of Android bugreport (or meminfo/procrank)

1.1. Meminfo

meminfo log file helps to collect system-wide memory information, which is always recorded during
system is running. Meminfo contains information like total memory, free memory, cached memory and
others. When memory leakage happens, it is expected to show the memory data-changing trend.

1.2. Procrank

Procrank log file shows application memory usage (RSS and PSS) ranking in periodic. Compare with meminfo,
it is detailed information to detect which application may cause memory leakage.

1.3. Kmemleak

Kmemleak is a tool to detect suspicious memory leakage in kernel. From the kmemleak log file, it is
expected to find most frequent occurrence of suspicious call stack.

1.4. ANR and Sigkill

This tool also detects ANR and Sigkill messages from Android event logs. ANR is "Android Not Response".

1.5. Android Bugreport

Bugreport is used in Android to generate a full report of system. It can be triggered by "adb shell bugreport"

2. Solution
-----------

Firstly, parse all meminfo in log file. And generate the curves of each entry of meminfo. From the curve,
it is expected to get the overview determine whether there is system-wide memory leakage, according to the
meminfo entry’s increment trend.

Generate kmemleak statistics, and then get the most frequently occurred entries for further analysis.

Generate process list and their memory usage (RSS/PSS) curves to determine abnormal ones. This analysis
should be operated on those specific process like Launcher, system_server, acore etc.

This tool can generate all above information and curve charts in PDF. It is expected to be flexible
to add more memory log entries for further analysis. This memory tool is developed with python and reportlab.

3. HOWTO
--------

3.1. Config environment

Python and Reportlab is required
$ sudo apt-get install python
$ sudo apt-get install python-reportlab

3.2. Usages

- brdiff.py
$ python brdiff.py –help
$ python brdiff.py bugreport_A.txt bugreport_B.txt -o /tmp/report
$ python brdiff.py procrank_A.txt procrank_B.txt -o /tmp/report
$ python brdiff.py meminfo_A.txt meminfo_B.txt -o /tmp/report
$ python brdiff.py  -o /tmp/report bugreport_A.txt bugreport_B.txt

- mmparse.py
$ python mmparse.py

3.3. Notes

- brdiff.py
Need two files as input parameters
If use -o option, generate report will be named as specified
If there is no -o option, default report name is “Memory Compare YYYY-MM-DD.pdf”

- mmparse
This tool will read memlog.txt (meminfo log) and memlog_procrank.txt (procrank). And generate a analysis report in PDF.

About

Memory logger analysis / comparison tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages