The article is mainly introduce how to crossing compile valgrind and using valgrind to check memory leak for app file and executable file
References: http://www.itdadao.com/articles/c15a376180p0.html http://blog.csdn.net/roland_sun/article/details/46049485 https://gist.github.com/mnemonicflow/131eb830a4d74911bf5a https://sergiolima.WordPRess.com/2015/07/07/vallgrind-and-android-working-together/ https://wiki.linaro.org/Platform/Android/UseValgrindOnAndroid
http://valgrind.org, and we can get lots of valgrind infomation from the website
Before compile valgrind file, we can reference the README.android, which is mainly introduce how to compile valgrind step by step.
valgrind-3.12.0.tar.bz
The following cmd must be execute in one line, and there is no “/n”, or there will be make error.
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-arm" CFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-arm" ./configure --prefix=/data/local/valgrind --host=armv7-unknown-linux --target=armv7-unknown-linux --with-tmpdir=/sdcardmake -j4make -j4 install DESTDIR='pwd'/valgrindcp valgrind /data/local/
before check memory-leak, you can use the following start_vgl.sh, and set export VALGRIND_LIB=/data/local/valgrind/lib/valgrind.
if [ "$APP" ]; then echo "check $APP memory leak" VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=memcheck --leak-check=full --show-reachable=yes' export TMPDIR=/data/data/$APP exec /data/local/valgrind/bin/valgrind $VGPARAMS $*# am force-stop app# setprop wrap.app "logwrapper /data/logcal/valgrind/start_vgl.sh"else echo "APP is null, check BIN file"# check bin memory leak if [ "$BIN" ]; then echo "check $BIN memory leak" BIN_CHECK='--tool=memcheck --leak-check=yes --show-reachable=yes' exec /data/local/valgrind/bin/valgrind $BIN_CHECK $BIN /data/local/valgrind/bin_leak.txt 2>&1 echo "store the output file to app_leak.txt" else echo "BIN is null, please input bin file" fififor check app, export $APP=”org.droidtv.helloworld”for check exe, exprot $BIN=”helloworld” And then run the start_vgl.shmaybe you can download the valgrind tool for checking memory-leak, but i am not sure it can run on your platform.
https://code.csdn.net/gonghuixue/philips_tv_apps/tree/master/valgrind.tar
新闻热点
疑难解答