[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Thread: memory leak when using not detached thread?
From: |
Gernot Hillier |
Subject: |
Re: Thread: memory leak when using not detached thread? |
Date: |
Wed, 11 Dec 2002 09:26:51 +0100 |
User-agent: |
KMail/1.4.3 |
Hi!
On Tuesday 10 December 2002 15:19, David Sugar wrote:
> A thread cannot delete it's own context or join itself. To make a thread
> that is a self running object that self-deletes, one has to detach the
> thread.
Ok, hope I understood it now. Thx!
Could you add a comment like (slightly modified)
"Note: A thread cannot delete it's own context or join itself. To make a
thread that is a self running object that self-deletes, one has to detach the
thread by using detach() instead of run()."
to the explanation of
virtual void ost::Thread::final(void)?
Would be great and help others to avoid the pitfall I stepped in. Thx!
I prepared a small patch for this. See attachment.
> However, there is very definately a known bug in at least some
> glibc releases that when a detached thread exits, it will not clean up
> it's stack frame allocations because that code only existed in the
> pthread_join implimentation, and, of course, one cannot self join...
With using detach() instead of start() and "delete this" in final(), the
resources get deleted here. I use glibc-2.2.5 (SuSE package -164), so I think
it's fixed in the meanwhile.
--
Bye,
Gernot
"Der Horizont vieler Menschen ist ein Kreis mit Radius Null - und das nennen
sie ihren Standpunkt." (A. Einstein)
note.diff
Description: Text Data