How to debug memory leakage in media server in Android

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to debug memory leakage in media server in Android

How to debug memory leakage in media server in Android

  • Check memory leakage in media server.
    • Set libc debug level. So libc will record back trace for all memory allocate.
      • setprop libc.debug.malloc 1
    • Kill mediaserver to let the libc debug take effect. Android will restart mediaserver.
      • busybox killall -HUP mediaserver
  • you will see below log if you setting right.
  • I/libc    ( 3074): /system/bin/mediaserver using MALLOC_DEBUG = 1 (leak checker)
  • Dump all used memory of mediaserver.
    • dumpsys media.player -m
    • Allocation count 297
    • Total memory 1483423
    • size   262144, dup    1, 0x401f4c18, 0x400b6152, 0x401a6568, 0x4061a95c, 0x40146cfa, 0x4019639c, 0x40146ec2, 0x4014a1ec, 0x4014a3ca, 0x00008a98, 0x400b67aa
    • size   178192, dup    1, 0x401f4c18, 0x400b6152, 0x4280adae, 0x427ffcee, 0x4280ae6c, 0x427ec75a, 0x427f7e22, 0x42807648, 0x428082ea, 0x415144f0, 0x4151334a, 0x413381d0, 0x401dcbc, 0x401d438c, 0x4014d996, 0x405c3c46, 0x405c7516, 0x405c6ad4, 0x412c02ca, 0x412c0584, 0x4108c64c, 0x4107d622, 0x4107fbf2, 0x4107c19a, 0x400b2eac, 0x400b2a00
  • Diff two times of memory dump to check if there is any memory leakage. You can playback one video file between the dump.
    • diff 1.txt 2.txt > diff.txt
    • Get maps file of mediaserver.
      • adb pull proc/<pid of mediaserver>/maps .
    • Use attached script to map back trace to function symbols and file line.
      • ./addr2func.py --root-dir=../../ --maps-file=./maps --product=sabresd_6dq diff.txt
  • Notes: should use eng build for the debug.


Attachments
Comments

Great!!

%3CLINGO-SUB%20id%3D%22lingo-sub-1102257%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHow%20to%20debug%20memory%20leakage%20in%20media%20server%20in%20Android%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1102257%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CUL%3E%3CLI%3ECheck%20memory%20leakage%20in%20media%20server.%20%3CUL%3E%3CLI%3ESet%20libc%20debug%20level.%20So%20libc%20will%20record%20back%20trace%20for%20all%20memory%20allocate.%20%3CUL%3E%3CLI%3Esetprop%20libc.debug.malloc%201%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EKill%20mediaserver%20to%20let%20the%20libc%20debug%20take%20effect.%20Android%20will%20restart%20mediaserver.%20%3CUL%3E%3CLI%3Ebusybox%20killall%20-HUP%20mediaserver%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3Eyou%20will%20see%20below%20log%20if%20you%20setting%20right.%3C%2FLI%3E%3CLI%3EI%2Flibc%26nbsp%3B%26nbsp%3B%26nbsp%3B%20(%203074)%3A%20%2Fsystem%2Fbin%2Fmediaserver%20using%20MALLOC_DEBUG%20%3D%201%20(leak%20checker)%3C%2FLI%3E%3CLI%3EDump%20all%20used%20memory%20of%20mediaserver.%20%3CUL%3E%3CLI%3Edumpsys%20media.player%20-m%3C%2FLI%3E%3CLI%3EAllocation%20count%20297%3C%2FLI%3E%3CLI%3ETotal%20memory%201483423%3C%2FLI%3E%3CLI%3Esize%26nbsp%3B%26nbsp%3B%20262144%2C%20dup%26nbsp%3B%26nbsp%3B%26nbsp%3B%201%2C%200x401f4c18%2C%200x400b6152%2C%200x401a6568%2C%200x4061a95c%2C%200x40146cfa%2C%200x4019639c%2C%200x40146ec2%2C%200x4014a1ec%2C%200x4014a3ca%2C%200x00008a98%2C%200x400b67aa%3C%2FLI%3E%3CLI%3Esize%26nbsp%3B%26nbsp%3B%20178192%2C%20dup%26nbsp%3B%26nbsp%3B%26nbsp%3B%201%2C%200x401f4c18%2C%200x400b6152%2C%200x4280adae%2C%200x427ffcee%2C%200x4280ae6c%2C%200x427ec75a%2C%200x427f7e22%2C%200x42807648%2C%200x428082ea%2C%200x415144f0%2C%200x4151334a%2C%200x413381d0%2C%200x401dcbc%2C%200x401d438c%2C%200x4014d996%2C%200x405c3c46%2C%200x405c7516%2C%200x405c6ad4%2C%200x412c02ca%2C%200x412c0584%2C%200x4108c64c%2C%200x4107d622%2C%200x4107fbf2%2C%200x4107c19a%2C%200x400b2eac%2C%200x400b2a00%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EDiff%20two%20times%20of%20memory%20dump%20to%20check%20if%20there%20is%20any%20memory%20leakage.%20You%20can%20playback%20one%20video%20file%20between%20the%20dump.%20%3CUL%3E%3CLI%3Ediff%201.txt%202.txt%20%26gt%3B%20diff.txt%3C%2FLI%3E%3CLI%3EGet%20maps%20file%20of%20mediaserver.%20%3CUL%3E%3CLI%3Eadb%20pull%20proc%2F%3CPID%20of%3D%22%22%20mediaserver%3D%22%22%3E%2Fmaps%20.%3C%2FPID%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EUse%20attached%20script%20to%20map%20back%20trace%20to%20function%20symbols%20and%20file%20line.%20%3CUL%3E%3CLI%3E.%2Faddr2func.py%20--root-dir%3D..%2F..%2F%20--maps-file%3D.%2Fmaps%20--product%3Dsabresd_6dq%20diff.txt%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3E%3CSTRONG%3ENotes%3C%2FSTRONG%3E%3A%20should%20use%20eng%20build%20for%20the%20debug.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSPAN%20class%3D%22mce_paste_marker%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1102258%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20How%20to%20debug%20memory%20leakage%20in%20media%20server%20in%20Android%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1102258%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EGreat!!%3C%2FP%3E%3C%2FLINGO-BODY%3E
No ratings
Version history
Last update:
‎09-12-2012 10:27 PM
Updated by: