$ adb pull /proc/<mediaserver_pid>/maps .
$ adb pull /data/memstatus_1136.0 .
$ adb pull /data/memstatus_1136.1 .
And I also updated the script to skip libc_debug.so while parsing symbols.
Thank you for the information. You've done a lot work here. Can you please state the Android version along with your findings?
The patch was based on Eclair, and also applicable on the master branch.
I tried your steps to analyse memory leak. But I have a few doubts.
I was able to get initial heap allocations of mediaserver process. Then i tried playing a file and again tried to run memorydumper as you have mentioned in step 4. But I couldn't get any dump since the execution of memorydump didnt stop ( even after i closed the application). Could you please tell if there is anything else i need to do?
My other doubt is in the python script, is the mapfile you are talking of is the one which will be in /proc/pid/maps or the memstatus_pid.maps in /data folder?. Also could you please upload a sample output file? I am trying to check memory leaks in gstreamer ported on android.
Thanks a lot for replying. The execution of memorydumper was taking a very long time because my count value was very large ( was around 9000). Now after getting the dumps, and after running the python script I am not able to figure out how to proceed in finding out the memory leaks. It would be of of great help if you could upload a sample output file and tell how to proceed in finding out where and how much memory is leaking. Thanks a lot again.
2) dup: how many times the malloc has been executed with the same call stack.
3) the backtrace when malloc is invoked.
The script just translates the hex addresses of the call stacks into file&function names.
So if you got a diff file where the dup number keeps increasing for some stack traces after testing, then it's very likely the allocated memory hasn't been freed appropriately, which needs to be investigated case by case.
A typo needs correction here.
$ adb shell pull /proc//maps .
$ adb pull /proc//maps .
Getting a crash when I run memorydumper.
To reproduce, open and close the camcorder app. Then run the memorydump.
thanks for nice information. please clarify my doubts.
for step 6 i am not able to run python file. please provide more info. as i am testing on device, to run python file should i have to install python and then run. or where should i place that pyton file. is it on /system/bin/ or /data.
The original steps were for Eclair. On Froyo, you'll need to follow the updated steps to set the property of libc.debug.malloc to 1, then restart mediaserver process before testing.
--> on froyo device. i am running memorydumper service attched my own native process.
able to get initial files.
memstatus_pid.0 and memstatus_pid.0.maps, smaps, statm files with valid content.
while getting memstatus_pid.1 file i am getting crash. i could able to see log as "enter dumpHeap".
Can you please help me get this?
I tried the steps mentioned above to setup memorydump and also got the memory dump files.
In order to check how it works, I deliberately added a memory leak of 200 bytes in Mpeg4Extractor for everytime a read is called. I expected the memory allocation of 200 bytes to be shown in the memory dump output file when I run the command addr2func.py. But I dont find the allocation at all. Any pointers on what can be the possible cause for this ?
Will this patch work for Gingerbread.
Thanks for very useful info!!
I have tried with the steps you have provided & able to get memory dump, which has size, dup & call backtrace info.
However I want to understand more to find out memory leak.
Does it mean all the chucks of data which are tracked are having mem leak?
size, dup & back trace info. How to find where exactly is the possibility of mem leak.
Sachin, yes, the patch is a bit out-dated. And you can skip the memorydumper patch related steps here and use the built-in dumpsys tool directly, then resolve the symbols with the python script.
First, Thank you for the information.
And I get below information.
How analyze this information ?
If you know, Please inform me.
It was very helpful for investigating the mediaserver memory leak issue that I had. Thank you very much.
But the script was too old for latest version of Android and when it cannot find the symbolic so, it just stops the script.
I just modified your script very lightly to use it for my case. I uploaded modified script into my github. I mentioned the origin in Readme file but If you don't like me to upload it there, Please let me know.
Thanks for your share, it's very helpful for us. It works fine on Android L, but something wrong on Android M. So do you have tried this method on Android M ?