2

I have tried following istrucions here. to debug my app because it uses C libraries and C memory allocation (I use libgdx) it seems to me that I have a leak in my app but the instructions on the link above say you need an eng phone so I rooted an hct one s and then I have found the following instructions I have found on several websites:

install busybox

adb shell
su

//beware of the following command as you have to type:

mount 

//first and then check where /system is in the list

//ext4 and /dev/block/mmcblk0p33 may have to be replaced

mount -o rw,remount -t ext4 /dev/block/mmcblk0p33 /system


cp /system/lib/libc.so /system/lib/libc_original.so

cp doesn't work

cat /system/lib/libc.so > /system/lib/libc_original.so

!!beware this breaks phone check if /system/lib/libc_debug.so exists

 adb shell mv /system/lib/libc_debug.so /system/lib/libc.so

So luckily after the last command my phone just rebooted and it's working.

Now I have realised, I don't know where to find libc_debug.so, any ideas? phone is htc one s, android 4.1.1. Where are the libs to be found? with source code?

Next question: is i safe to just replace /system/lib/libc.so by /system/lib/libc_debug.so?

Has any body done that, does it even work?

Dennis Kriechel
  • 3,719
  • 14
  • 40
  • 62
vallllll
  • 2,731
  • 6
  • 43
  • 77

1 Answers1

2

You could try cross-compiling valgrind and using that to debug your memory leaks. Not sure how you are doing your development but, if you checkout AOSP you get valgrind in the external/valgrind and gdb and you can build and drop them onto the device you are trying to debug. Dunno if that might help.

Update: Here is a similar approach to what you are doing. They perfomed the steps you did restarted frameworks and then used DDMS to profile for memory leaks, How to Find memory leaks from native code in android and a similar post in a google groups thread seems like thats an alternative.

Community
  • 1
  • 1
dudebrobro
  • 1,287
  • 10
  • 17
  • thanks Quentin, I had a look at valgrind but it seems quite complex and I don't have a nexus S. Do you know of any simpler way? I don't need to debug the C libraries I am using I just would like to see if maybe some of the C objects I create may be leaked. The problem is my app after a while just gets killed. I mean it doesn't crash it just disappears and there are no error logs. – vallllll Aug 06 '13 at 10:09
  • Updated with some information on ddms looks like some people generally do what you did set a property on the phone and then use [ddms](http://developer.android.com/tools/debugging/ddms.html) to try and track down memory leaks. Hope that helps some. – dudebrobro Aug 06 '13 at 12:00
  • thks I have done % adb shell setprop libc.debug.malloc 1 % adb shell stop % adb shell start and it doesn't change the Native tab in ddms is still empty I have htc one s android 4.1.1 rooted. still there a re some logs about allocations that will help me – vallllll Aug 08 '13 at 11:53