Subj : Re: memory leak in pthread_create To : comp.programming.threads From : Torsten Robitzki Date : Tue Jun 07 2005 01:06 am Threads wrote: > Hi, > I am experiencing memory leak in pthread_create. > Here is the code snippent where valgrind has reported memory leak > ........... > ........... > pthread_t id; > pthread_create( &(thread->m_threadID), NULL, > &PSThread::threadFunction, (void *)thread); > id = thread->m_threadID; > ........... > > > > valgrind report displays > 8160 bytes in 1 blocks are definitely lost in loss record 267 of 298 > at 0x1B9005F7: malloc (vg_replace_malloc.c:130) > by 0x1BC81CA4: __pthread_initialize_manager (in /lib/libpthread-0.9.so) > by 0x1BC82B64: pthread_create@@GLIBC_2.1 (in /lib/libpthread-0.9.so) > by 0x8147AF6: PSThreadCreator::internalFireThread(PSSocket*, PSThread*) > (PSThreadCreator.cpp:93) > by 0x80A5858: > PSESQLThreadCreator::PSESQLThreadCreator(PSConnectionManager&, > PSESqlEngineManager&, PSEDirManager&, PSESchema&, PSEConfigFile&) > (PSESQLThreadCreator.cpp:204) > by 0x8091123: main (UnixMain.cpp:417) > > > It would be great if you provide any poitner to resolve this memory > leak issue. I think what you see are the memory resources needed by the thread management to keep track of your created thread. They can not be release before the created thread has been joined. Try to join the spawned thread and see if your problem still exists. Do you know if valgrind scans the whole memory for references to memory to find lost references? I don't know but the message suggests something like this. And as there are more than one pthread implementations, it might be useful to mind the one in use ;-) regards Torsten .