linux profile valigrind 分析工具,是否有任何可以捕获此内存泄漏的静态代码分析器?...

e.g.

#include

void foo(void) {

int *ptr = (int *)malloc(512);

ptr = (int *)0xffffffff;

free(ptr);

}

int main(){

foo();

return 1;

}

Valigrind Output:

[[email protected] /tmp]# valgrind --tool=memcheck --leak-check=full ./Ex1

==23780== Memcheck, a memory error detector

==23780== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.

==23780== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info

==23780== Command: ./Ex1

==23780==

==23780== Invalid free()/delete/delete[]

==23780== at 0x4A05A31: free (vg_replace_malloc.c:325)

==23780== by 0x400509: foo (in /tmp/Ex1)

==23780== by 0x400514: main (in /tmp/Ex1)

==23780== Address 0xffffffff is not stack'd, malloc'd or (recently) free'd

==23780==

==23780==

==23780== HEAP SUMMARY:

==23780== in use at exit: 512 bytes in 1 blocks

==23780== total heap usage: 1 allocs, 1 frees, 512 bytes allocated

==23780==

==23780== 512 bytes in 1 blocks are definitely lost in loss record 1 of 1

==23780== at 0x4A05E1C: malloc (vg_replace_malloc.c:195)

==23780== by 0x4004E9: foo (in /tmp/Ex1)

==23780== by 0x400514: main (in /tmp/Ex1)

==23780==

==23780== LEAK SUMMARY:

==23780== definitely lost: 512 bytes in 1 blocks

==23780== indirectly lost: 0 bytes in 0 blocks

==23780== possibly lost: 0 bytes in 0 blocks

==23780== still reachable: 0 bytes in 0 blocks

==23780== suppressed: 0 bytes in 0 blocks

==23780==

==23780== For counts of detected and suppressed errors, rerun with: -v

==23780== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值