Overview
Features
Download
Documentation
Community
Add-Ons & Services

Poco::Thread leak on Linux

Please post support and help requests here.

Poco::Thread leak on Linux

Postby rd » 07 Feb 2013, 12:43

Hi,

It seems to me there is a problem when using a Poco::Thread on linux when you do not call join() on it and the thread function simply finishes before the Thread object destructor is called.

The destructor only calls pthread_detach() if isRunningImpl() is true, but if the ThreadImpl::runnableEntry(void* pThread) function finishes, it will set pData->pRunnableTarget = 0, so isRunningImpl() will return false then.

This causes the virtual memory usage of the process to increase with every thread, an after a few hundred started&stopped threads you will get "cannot start thread" exceptions.

Code: Select all
Thread_POSIX.cpp:

ThreadImpl::~ThreadImpl()
{
   if (isRunningImpl())
      pthread_detach(_pData->thread);
}
rd
 
Posts: 19
Joined: 16 Jun 2007, 15:30

Re: Poco::Thread leak on Linux

Postby alex » 07 Feb 2013, 14:27

Looks like a bug. Filed a bug report, will look into it for next release.
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Poco::Thread leak on Linux

Postby rd » 07 Feb 2013, 15:01

Thanks,

I guess I will until then revert to always using Poco::ThreadPool because this way threads will always be joined so there will be no leaks.

Best regards,

Ronny Dierckx
rd
 
Posts: 19
Joined: 16 Jun 2007, 15:30

Re: Poco::Thread leak on Linux

Postby alex » 08 Feb 2013, 00:58

rd wrote:I guess I will until then revert to always using Poco::ThreadPool because this way threads will always be joined so there will be no leaks.

Now, if you really need this and prefer to see it sooner rather than later, it would help if you can fix the bug, write a test and send back a GitHub pull request.
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Poco::Thread leak on Linux

Postby alex » 18 Mar 2013, 04:18

alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 10 guests