Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory debugging tools for Android NDK C++ code

Does anyone know of memory debugging tools (like Valgrind) for native C++ code under Android NDK?

like image 452
Ravi Avatar asked Dec 15 '10 02:12

Ravi


People also ask

What is Android NDK tools?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.

How do you find memory leaks in an application on the Android platform?

The Memory Profiler is a component in the Android Profiler that helps you identify memory leaks and memory churn that can lead to stutter, freezes, and even app crashes. It shows a realtime graph of your app's memory use and lets you capture a heap dump, force garbage collections, and track memory allocations.

What compiler does Android NDK use?

Code written in C/C++ can be compiled to ARM, or x86 native code (or their 64-bit variants) using the Android Native Development Kit (NDK). The NDK uses the Clang compiler to compile C/C++.


1 Answers

We have a project that uses quite a bit of native code. As hinted in one of the comments for the question, the best approach is to test that code on another environment.

We have a separate project that builds in Linux and calls the C/C++ functions we use in our Android code. Once you are at that point, all the nice tools you are used to (gdb, Valgrind, etc.) are available to you.

A lot more productive than doing the same thing on the phone (assuming you could even find a good tool).

The tricky part is to have a good test harness, but that should be a given to any project that started off on the right path... ;)

like image 194
Christian Garbin Avatar answered Sep 21 '22 23:09

Christian Garbin