打赏

Cgo内存管理

Cgo内存管理

Valgrind安装和使用

方法一

wget http://valgrind.org/downloads/valgrind-3.9.0.tar.bz2
tar xvf valgrind-3.9.0.tar.bz2
cd valgrind-3.9.0/
./configure
make
make install

方法二:

sudo apt-get install valgrind

使用:

valgrind --tool=memcheck --leak-check=full valgrind_demo
valgrind --leak-check=full ./xxx

打印内存信息:

var m runtime.MemStats
runtime.ReadMemStats(&m)
log.Printf("Alloc = %v TotalAlloc = %v Sys = %v NumGC = %v\n", m.Alloc/1024, m.TotalAlloc/1024, m.Sys/1024, m.NumGC)

相关链接

https://pengrl.com/p/29054/
https://www.jianshu.com/p/7ce24f278b0e
https://shengping.space/2018/08/30/012_golang之cgo/
https://www.cnblogs.com/magicsoar/p/7002467.html
https://m.php.cn/be/go/455798.html
https://smileusd.github.io/2018/07/02/golang-map/

posted @ 2021-04-06 13:44  苍山落暮  阅读(307)  评论(0编辑  收藏  举报