##环境
pc: ubuntu 16.04
toolchain:aarch64-agl-linux
embedded system: linux 4.14
##交叉编译
使用valgrind-3.17目录下的./configure 确认配置选项,使用脚本确定选项,
如下:
#!/bin/sh
/home/user/Downloads/valgrind-3.17.0/configure \
--prefix=/home/user/Downloads/install_valgrind_arm64 \
--host=aarch64-agl-linux \
--enable-only64bit
运行上述脚本,产生MakeFile文件,使用make进行编译,然后make install。
##嵌入式环境配置
嵌入式开发板上的目录确保要和prefix一致(这里是/home/user/Downloads/install_valgrind_arm64),同时使用export VALGRIND_LIB=/home/user/Downloads/install_valgrind_arm64/lib/valgrind 配置环境变量。
但运行工具会发现被错(找不到massif-arm64及memcheck-arm64,以及vgpreload和vgcore),需要单独从工具编译路径找到对应的库推送到VALGRIND_LIB配置的目录下。
##使用massif
上述配置做完后,即可运行valgrind。
valgrind --tool=massif --pages-as-heap=yes
使用contron+c 退出执行,会生成对应的massif.out. 文件
运用ms_print/massif-visualizer分析massif.out文件即可看到内存消耗分布