bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threads leak?


From: David Sugar
Subject: Re: Threads leak?
Date: Sat, 10 Apr 2004 06:12:32 -0400
User-agent: KMail/1.6.2

I did read this somewhere:

"...pthread_setspecific may be called from a thread-specific data destructor 
function, however this may result in lost storage or infinite loops...."

If a thread is deleted it may invoke terminate from it's own destructor, in 
certain appropriate cases, and in the posix implementation, this currently 
sets:  

        if(getThread() == this)
                _self.setKey(DUMMY_INVALID_THREAD);

Actually, I think this should happen if getThread() != this or maybe could be 
left out entirely, as _self.setKey() does invoke pthread_setspecific, and may 
well do so from a destructor.  If you remove that from thread.cpp, do you 
still see a memory leak in your code?

On Wednesday 07 April 2004 11:18 am, Gabor Szabo wrote:
> Hi there,
>
>
> In my program I had to repetitively create, run and destroy
> threads with the Thread class, and noticed that the memory
> footprint of the process just keeps growing (as shown by top). I
> have attached two pieces of code, one with the Thread class, and
> one using pthreads, both performing the same operations from this
> point of view. While the memory usage of the pthreads one does
> not increase, this is not true for the CC++ example. I am using
> Common C++ 1.1.0.
>
> I have looked at the source code of Threads, but did not see any
> indication of why this is happening.
>
>
> Gabor Szabo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]