国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

how to debug memory-leak

2019-11-09 17:33:27
字體:
供稿:網(wǎng)友

1: valgrind introduce http://valgrind.org/docs/manual/mc-manual.html

2: make/run valgrind in host platform - 列表內(nèi)容 - wget http://www.valgrind.org/downloads/valgrind-3.8.1.tar.bz2 - tar xvf valgrind-3.8.1.tar.bz2 - cd valgrind-3.8.1 - ./configure –PRefix=/usr/local/webserver/valgrind - make - make install

3: how to use valgrind http://blog.csdn.net/21aspnet/article/details/8172124 http://blog.csdn.net/sduliulun/article/details/7732906 http://blog.chinaunix.net/uid-23629988-id-3033741.html

#include <stdlib.h> int* func(void) { int* x = malloc(10 * sizeof(int)); x[10] = 0; //問題1: 數(shù)組下標(biāo)越界 } int main(void) { int* x=NULL; x=func(); //free(x); x=NULL; return 0; //問題2: 內(nèi)存沒有釋放 }

編譯 $gcc -g -o test test.c

內(nèi)存檢查 $ valgrind –tool=memcheck –leak-check=yes –show-reachable=yes ./test

報(bào)告:

說明 Invalid write of size 4:表示數(shù)組越界寫了4字節(jié) 40 bytes in 1 blocks:表示因程序退出而發(fā)生內(nèi)存泄露40字節(jié)

文檔: Valgrind 中包含的 Memcheck 工具可以檢查以下的程序錯(cuò)誤:

  使用未初始化的內(nèi)存 (Use of uninitialised memory)   使用已經(jīng)釋放了的內(nèi)存 (Reading/writing memory after it has been free’d)   使用超過malloc分配的內(nèi)存空間(Reading/writing off the end of malloc’d blocks)   對堆棧的非法訪問 (Reading/writing inappropriate areas on the stack)   申請的空間是否有釋放 (Memory leaks – where pointers to malloc’d blocks are lost forever)   malloc/free/new/delete申請和釋放內(nèi)存的匹配(Mismatched use of malloc/new/new [] vs free/delete/delete [])   src和dst的重疊(Overlapping src and dst pointers in memcpy() and related functions)   重復(fù)free

4: references http://blog.csdn.net/yangzhiloveyou/article/details/7935078 http://www.cnblogs.com/shuaihanhungry/p/5818713.html

cross compile valgrind 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/


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 商城县| 宝坻区| 榆林市| 崇明县| 渝北区| 宣恩县| 灵璧县| 永康市| 若羌县| 泉州市| 黑龙江省| 通州区| 襄垣县| 密云县| 临洮县| 光山县| 兴化市| 鄂托克前旗| 新闻| 巴里| 卢氏县| 桃江县| 南京市| 林州市| 无极县| 绿春县| 徐州市| 孟村| 南安市| 桃江县| 寿宁县| 饶河县| 木里| 镇宁| 嘉祥县| 昌黎县| 昆山市| 化州市| 黄平县| 柯坪县| 宽城|