getting malloc debug for specific android program


I want to get the back trace dump (malloc debug) of an android device. Im doing this via ADB terminal access, linux platform, root

do i need to restart the target progam first only then the kill -47 <pid> to get the back trace heap dump will success?

for now the steps i did was:

  1. on terminal 1: setprop libc.debug.malloc.options "backtrace leak_track verbose guard"

  2. on terminal 1: setprop libc.debug.malloc.program <target native program> (example audioserver)

  3. on terminal 2: logcat | grep malloc_debug

  4. on terminal 3: ps -ef | grep <target native program> (example audioserver)

  5. on terminal 1: kill -47 <pid of target program> (retrieved at #4)

  6. after few minutes wait, when i check in terminal 2, nothing appear saying it dumping the back trace heap

  7. when i check in the target dir to dump the back trace heap also there is nothing, no back trace heap txt file.

Note:

I managed to get the back trace heap txt file ONLY WHEN i kill/restart the target program. refer below how i do it

  1. after step #4, using the pid returned, i kill the target program by doing "kill -9 <pid of target program>"

  2. then at terminal 2: message will say

    11-06 13:39:26.226 22650 22650 I malloc_debug: ls: Run: 'kill -47 1234' to dump the backtrace.
    
    11-06 13:39:26.227 22650 22650 I malloc_debug: ls: malloc debug enabled
    
  3. then at terminal 1, i do `kill -47 1234`

  4. the back trace heap dump txt successfully created in the target dir

So, my question is, do i really need to make the target program restarted first?
restarted via any way/method such as:

  1. force stop the app using force stop button or

  2. simply just reboot the device (quick one) or

  3. use kill -9 command

-1
Nov 18 at 10:33 AM
User Avatarnsiderscodes
#android#malloc#adb#heap-memory#native

No answer found for this question yet.