tech-userlevel archive

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

Re: Possible pthreads memory leak (Matthew Mondor) writes:

> (Michael van Elst) wrote:
>> and the pullup to netbsd-5 branch occured 6 days ago...

>ident(1) shows that I have, so my tests were done with the
>fix applied.  This probably explains the more serious leaks Zach
>experiences on 5.0.1.  Is it still expected that without inserting a
>syscall to cause a context switch a small leak still occurs over time
>with the fix?

The pthread library doesn't free the thread stack when a thread
exits but reuses it when creating a new thread. Due to a race
condition with the kernel, the "reuse" may fail. However, this
loss should not grow beyond a limit set by the concurrency of the

So no, there shouldn't be a constant memory leak. A -current/amd64
system shows a growth from 14M to 22M but then seems to be stable,
which means that it lost memory for 4 threads (with 2M stack each).

                                Michael van Elst
                                "A potential Snark may lurk in every tree."

Home | Main Index | Thread Index | Old Index