3

What is the way to find memory leaks that are in ndk C code in android studio? As every one on google and stackoverflow refer to ddms for memory leaks in ndk C code but ddms is no longer present in android sdk as described in the following link How to Find memory leaks from native code in android

It also does not help as there is no way to run ddms.

Waqas Ahmed
  • 1,321
  • 1
  • 14
  • 23
  • I want to find memory leaks in ndk c code – Waqas Ahmed Aug 20 '17 at 07:44
  • I think you need to look at AddressSanitizer and Valgrind tools for getting memory leaks from native ndk C code in android. I am struggling with the same problem here. I was able to run my app using valgrind, but it slows down the application too much. I am currently looking at Address Sanitizer. If you already have the solution can you kindly let me know. – user2284140 Sep 08 '17 at 18:53

2 Answers2

-1

Use LeakCanary.

The description on how to implement that in code is well described in Getting started

Aveek
  • 849
  • 1
  • 12
  • 28
-2

Setup LeakCanary

Go through the description in Readme to setup.

In your build.gradle:

dependencies { debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.2' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.2' }

And initialise it in Application class

LeakCanary.install(this);
Nidhin Prathap
  • 696
  • 5
  • 15