使用valgrind进行内存检测,出现内存泄露情况 如下: [root@localhost Debug]# valgrind --tool=memcheck --leak-check=yes ./timeUse ==7258== Memcheck, a memory error detector ==7258== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==7258== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==7258== Command: ./timeUse ==7258== 11111 122334 11111 11111 11111 11111 ==7258== ==7258== HEAP SUMMARY: ==7258== in use at exit: 144 bytes in 1 blocks ==7258== total heap usage: 4 allocs, 3 frees, 352 bytes allocated ==7258== ==7258== 144 bytes in 1 blocks are possibly lost in loss record 1 of 1 ==7258== at 0x4005F0D: calloc (vg_replace_malloc.c:593) ==7258== by 0x389F29: _dl_allocate_tls (in /lib/ld-2.12.so) ==7258== by 0x56B34F: pthread_create@@GLIBC_2.1 (in /lib/libpthread-2.12.so) ==7258== by 0x59D131: __start_helper_thread (in /lib/librt-2.12.so) ==7258== by 0x5708DF: pthread_once (in /lib/libpthread-2.12.so) ==7258== by 0x804875B: SetTimer(void (*)(sigval), void*&, int, int) (main.cpp:38) ==7258== by 0x80487E3: main (main.cpp:55) ==7258== ==7258== LEAK SUMMARY: ==7258== definitely lost: 0 bytes in 0 blocks ==7258== indirectly lost: 0 bytes in 0 blocks ==7258== possibly lost: 144 bytes in 1 blocks ==7258== still reachable: 0 bytes in 0 blocks ==7258== suppressed: 0 bytes in 0 blocks ==7258== ==7258== For counts of detected and suppressed errors, rerun with: -v ==7258== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 17 from 8) [root@localhost Debug]#