LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 851|回复: 4

第一次 使用valgrind 碰到问题

[复制链接]
发表于 2005-10-1 21:24:28 | 显示全部楼层 |阅读模式
测试程序是:
//----------------------------------
#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
发表于 2005-10-1 22:10:44 | 显示全部楼层
你的问题是什么?
回复 支持 反对

使用道具 举报

发表于 2005-10-1 22:28:13 | 显示全部楼层
valgrind --tool=memcheck test <-- replace test with ./test
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-2 00:26:14 | 显示全部楼层
谢谢大家的帮助,可以了。。

linuxsir就是好
回复 支持 反对

使用道具 举报

发表于 2005-10-2 10:40:00 | 显示全部楼层
Post by sunmoon1997
valgrind --tool=memcheck test <-- replace test with ./test

呵呵,你还看得真仔细
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表