tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Possible pthreads memory leak
<note: John, I accidentally replied to you alone at first, sorry for
the double post>
On Sat, Jan 16, 2010 at 10:28 PM, john heasley <heas%shrubbery.net@localhost>
wrote:
>
> i think threads are attacahed by default, so you need to free the thread
> pointer ,etc. pthread_destory()
Hello John,
I guess you mean pthread_detach()? I never thought that that was
needed, and reading the man pages suggests that it's equivalent to a
non-blocking version of pthread_join. So pthread_join should
theoretically do the same cleanup that pthread_detach does, after the
child thread exits. And indeed, calling pthread_detach after
pthread_join (or vice versa) still leaks memory. pthread_detach
returns an error too (ESRCH), as I guess it should.
Not sure what to do now, I suppose I'll modify my program to keep a
thread pool around so this won't matter. Thanks for the help though.
Zach
Home |
Main Index |
Thread Index |
Old Index