2

What is the best way to detect memory leaks in native code built with the android NDK?

Is there any tool like valgrind that I could use?

rahul
  • 2,269
  • 3
  • 28
  • 31

1 Answers1

1

You load *.so library with System.loadLibrary, than call any jni functions. So you can define "startup" and "cleanup" functions - you can do your initialzation in former func and release all resources in latter. In this case it's possible to use any from large amount of available leak tracers - for example you can see following:

http://dmalloc.com/

http://www.andreasen.org/LeakTracer/

http://memwatch.sourceforge.net/

http://mpatrol.sourceforge.net/

About valgrind: https://stackoverflow.com/a/7815977/814297

Community
  • 1
  • 1
Andrey Starodubtsev
  • 5,139
  • 3
  • 32
  • 46