留下一个pthread_cancel内存泄露的问题。

C、C++和Java语言
回复
头像
arthur
帖子: 76
注册时间: 2006-08-13 16:06
送出感谢: 0
接收感谢: 0

留下一个pthread_cancel内存泄露的问题。

#1

帖子 arthur » 2007-05-18 16:08

使用pthread_cancel取消线程后会有一块内存没有释放,正在想办法解决。

如果有人知道怎么解决欢迎跟帖。

这是用valgrind监测后的报告:

代码: 全选

==15293== Memcheck, a memory error detector.
==15293== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==15293== Using LibVEX rev 1658, a library for dynamic binary translation.
==15293== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==15293== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==15293== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==15293== For more details, rerun with: -v
==15293== 
==15293== My PID = 15293, parent PID = 7435.  Prog and args are:
==15293==    ./wocsd
==15293== 
==15293== 
==15293== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 19 from 1)
==15293== malloc/free: in use at exit: 28 bytes in 1 blocks.
==15293== malloc/free: 15 allocs, 14 frees, 888 bytes allocated.
==15293== For counts of detected errors, rerun with: -v
==15293== searching for pointers to 1 not-freed blocks.
==15293== checked 127,544 bytes.
==15293== 
==15293== 28 bytes in 1 blocks are still reachable in loss record 1 of 1
==15293==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==15293==    by 0x400BE46: (within /lib/ld-2.5.so)
==15293==    by 0x4010DF4: (within /lib/ld-2.5.so)
==15293==    by 0x400CFA5: (within /lib/ld-2.5.so)
==15293==    by 0x40108ED: (within /lib/ld-2.5.so)
==15293==    by 0x42710A1: (within /lib/tls/i686/cmov/libc-2.5.so)
==15293==    by 0x400CFA5: (within /lib/ld-2.5.so)
==15293==    by 0x4271254: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.5.so)
==15293==    by 0x4044E66: pthread_cancel_init (in /lib/tls/i686/cmov/libpthread-2.5.so)
==15293==    by 0x404140B: pthread_cancel (in /lib/tls/i686/cmov/libpthread-2.5.so)
==15293==    by 0x80494E1: WOCS_TcpServer::stop() (tcpserver.cc:134)
==15293==    by 0x8049801: WOCS_TcpServer::~WOCS_TcpServer() (tcpserver.cc:36)
==15293== 
==15293== LEAK SUMMARY:
==15293==    definitely lost: 0 bytes in 0 blocks.
==15293==      possibly lost: 0 bytes in 0 blocks.
==15293==    still reachable: 28 bytes in 1 blocks.
==15293==         suppressed: 0 bytes in 0 blocks.
回复

回到 “C/C++/Java”