p编程中的pthread内存泄漏

我有下面的代码。

void *timer1_function(void * eit); pthread_t timer1; int thread_check1 = 0; line72: thread_check1 = pthread_create( &timer1, NULL, timer1_function, NULL); 

Valgrind显示下面的输出,并表示line 72存在问题。 上面的pthread_create用法有什么问题?

 272 bytes in 1 blocks are possibly lost in loss record 2 of 5 in main in main.c:72 1: calloc in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so 2: _dl_allocate_tls in /build/buildd/eglibc-2.15/elf/dl-tls.c:297 3: pthread_create@@GLIBC_2.2.5 in /build/buildd/eglibc-2.15/nptl/allocatestack.c:571 4: main in main.c:72 

创建线程时,可以使用它分配一些内存。 清理此内存的任务是通过调用pthread_join

在线程退出时不清除此内存的原因是这些数据包含诸如“线程的退出状态”之类的信息,父母可能希望稍后检出。 因此,永远不要join线程意味着永远不要清理那个内存。

未连接线程的概念类似于僵尸进程 。