Using Valgrind to Find Memory Leaks

   document.write ("height='120' οnmοuseοver='kevinloveada.stop()' οnmοuseοut='kevinloveada.start()'>") document.write ("偶然") document.write ("徐志摩") document.write (" ") document.write ("
我是天空里的一片云,") document.write ("
偶尔投影在你的波心―― ") document.write ("
你不必讶异, ") document.write ("
更无须欢喜―― ") document.write ("
在转瞬间消灭了踪影。") document.write ("
") document.write ("
你我相逢在黑暗的海上,") document.write ("
你有你的,我有我的,方向;") document.write ("
你记得也好, ") document.write ("
最好你忘掉, ") document.write ("
在这交会时互放的光亮! ") document.write ("") document.write (" ") Feedjit Live Blog Stats --> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); try { var pageTracker = _gat._getTracker("UA-7918401-1"); pageTracker._trackPageview(); } catch(err) {} Have Some Music height="68" name="Kingbeful" align="middle"type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflash player" border="0" style="visibility:visible;width:160px;height:68px; " /> var qbf_temp = 0; var stat = new String(" 欢迎你来 :)"); var num = stat.length; var dirction = 1; function test_s() { qbf_temp = qbf_temp + dirction; if (qbf_temp > num) { dirction = -1; } if (qbf_temp 舍得网 很不错的网站,注册之后用手机激活(免费),就能得到小礼品哦 --> 联系我 Communicate with me
  
  
  
  
  
  In Shell Type: > valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./test The it reports: ==5030==
  ==5030== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 12 from 1)
  ==5030== malloc/free: in use at exit: 16441 bytes in 3 blocks.
  ==5030== malloc/free: 33 allocs, 30 frees, 16648 bytes allocated.
  ==5030== For counts of detected errors, rerun with: -v
  ==5030== searching for pointers to 3 not-freed blocks.
  ==5030== checked 1401780 bytes.
  ==5030==
  ==5030== 15 bytes in 1 blocks are definitely lost in loss record 1 of 2
  ==5030== at 0x1B904984: malloc (vg_replace_malloc.c:131)
  ==5030== by 0x8049802: occ_cfg_gen_hier_str (occ_cfg_parse.y:256)
  ==5030== by 0x804910E: yyparse (occ_cfg_parse.y:165)
  ==5030== by 0x804997E: main (occ_cfg_parse.y:294)
  ==5030==
  ==5030==
  ==5030== 16426 bytes in 2 blocks are still reachable in loss record 2 of 2
  ==5030== at 0x1B904984: malloc (vg_replace_malloc.c:131)
  ==5030== by 0x804ABDD: yy_flex_alloc (lex.yy.c:2277)
  ==5030== by 0x804A867: yy_create_buffer (lex.yy.c:1957)
  ==5030== by 0x8049AE9: yylex (lex.yy.c:1182)
  ==5030==
  ==5030== LEAK SUMMARY:
  ==5030== definitely lost: 15 bytes in 1 blocks.
  ==5030== possibly lost: 0 bytes in 0 blocks.
  ==5030== still reachable: 16426 bytes in 2 blocks.
  ==5030== suppressed: 0 bytes in 0 blocks. what's the difference between "definitely lost", "indirectly lost", "possibly lost", "still reachable", and "suppressed"?
  The details are in the Memcheck section of the user manual.
  In short:
  "definitely lost" means your program is leaking memory -- fix those leaks!
  "indirectly lost" means your program is leaking memory in a pointer-based structure. (E.g. if the root node of a binary tree is "definitely lost", all the children will be "indirectly lost".) If you fix the "definitely lost" leaks, the "indirectly lost" leaks should go away.
  "possibly lost" means your program is leaking memory, unless you're doing funny things with pointers.
  "still reachable" means your program is probably ok -- it didn't free some memory it could have. This is quite common and often reasonable. Don't use --show-reachable=yes if you don't want to see these reports.
  "suppressed" means that a leak error has been suppressed. There are some suppressions in the default suppression files. You can ignore suppressed errors.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值