赞助连接

赞助连接

阅 读 文 章

socket结构体 内存泄露?

[来源:网上转载 (http://bbs.chinaunix.net) | 作者:网友(网络转载) | 时间:2008-06-14 | 浏览:人次 ]

IVR_Data_List *p = new IVR_Data_List;

recvLen = send(IVR_getsockfd, (char*)p, sizeof(IVR_Data), 0); //这样发送为什么会提示内存泄露?

==2453== Syscall param socketcall.send(msg) points to uninitialised byte(s)
==2453==    at 0x41E6666: send (in /lib/libc-2.3.2.so)
==2453==    by 0x804FE6D: main (in /home/mcn/lib/SServer)
==2453==  Address 0x4291074 is 12 bytes inside a block of size 64 alloc'd
==2453==    at 0x401AD61: operator new(unsigned) (vg_replace_malloc.c:224)
==2453==    by 0x804BBAE: CServer::Start_mcn() (in /home/mcn/lib/SServer)
==2453==    by 0x804FE6D: main (in /home/mcn/lib/SServer)

struct IVR_Data
{
char CLI[26] ;
char DNR[26] ;
unsigned long Last_time ;  
unsigned long Counter ;
};




没看到哪里提示内存泄露了。


没办法 开发了一个小server跑了 7天之后 *** 作系统的可用内存内消耗光了  在做内存泄露的检查
以上信息是这条语句跑出来的
valgrind -q --tool=memcheck --leak-check=full  ./a.out

=2453== Syscall param socketcall.send(msg) points to uninitialised byte(s)
==2453==    at 0x41E6666: send (in /lib/libc-2.3.2.so)
==2453==    by 0x804FE6D: main (in /home/mcn/lib/SServer)
==2453==  Address 0x4291074 is 12 bytes inside a block of size 64 alloc'd
==2453==    at 0x401AD61: operator new(unsigned) (vg_replace_malloc.c:224)
==2453==    by 0x804BBAE: CServer::Start_mcn() (in /home/mcn/lib/SServer)
==2453==    by 0x804FE6D: main (in /home/mcn/lib/SServer)

只是警告么?


"IVR_Data_List *p = new IVR_Data_List;"

where is the "delete" ?

ps: warrning is " uninitialised byte"  
                               ^^^^^^^^^^^^^^


IVR_Data_List *p; //内存的动态分配是在其他地方
while(it->second/*->IVL_Head*/ != NULL)
{
    p = it->second/*->IVL_Head*/;
    if  ( string(p->IVRD.DNR) != strLineResult[12])
    {
        recvLen = send(IVR_getsockfd, /*(char*)*/p, sizeof(IVR_Data), 0);
        memset(strSend, 0, sizeof(strSend));
        memset(strTime, 0, sizeof(strTime));
        memset(strCount, 0, sizeof(strCount));
        sprintf( strTime , "%d", p->IVRD.Last_time );
        sprintf( strCount, "%d", p->IVRD.Counter   );
        sprintf( strSend , "|%25s|%25s|%11s|%06s|", p->IVRD.CLI, p->IVRD.DNR , strTime ,strCount );
TAG标签 : 泄露 内存 结构 in by /home/mcn/lib/SServer sizeof

最新评论 共有0位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表
网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.chmhome.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.