|
|
测试程序是:
//----------------------------------
#include <stdio.h>
#include <stdlib.h>
int main()
{
int *p, i, a;
p = malloc(10*sizeof(int));
p[10] = 1;
p[11] = 1;
a = p[11];
free(p);
return 0;
}
//---------------------------------------
然后
# gcc -g test.c -o test
# valgrind --tool=memcheck test
出来的信息是:
==5581== Memcheck, a memory error detector for x86-linux.
==5581== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==5581== Using valgrind-2.4.1, a program supervision framework for x86-linux.
==5581== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==5581== For more details, rerun with: -v
==5581==
==5581==
==5581== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 1)
==5581== malloc/free: in use at exit: 0 bytes in 0 blocks.
==5581== malloc/free: 32 allocs, 32 frees, 2033 bytes allocated.
==5581== For counts of detected errors, rerun with: -v
==5581== No malloc'd blocks -- no leaks are possible.
而且不管我用什么程序下去测试结果都是这样。。。
我的机子是c4 2.0 + fedora core4 |
|