[osg-users] OpenThread leak ?
robert.osfield at gmail.com
Tue Sep 25 12:45:39 PDT 2007
On 9/25/07, Adam Coates <acoates at stanford.edu> wrote:
> I looked into this a tad more; it looks like it is indeed caused by
> the thread not being detached. I added the line:
> pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
> before the thread creation so that the thread will clean up
> automatically. This eliminates the memory leak. This is a bad hack,
> since it will break the join() and detach() functions. However,
> before I tried this, I tried calling join() and detach() on the Thread
> object, but that only leads to a segfault (not sure why yet).
Just a quick comment, in early days of OpenThreads/OSG development we
tried out join() but found problems with it and certain platforms. I
can't recall which platforms, nor which combinations of usage, nor the
actual symptoms exhibited - its was around 6 years ago.
As for a small memory leak on exit from an app, well unix will clean
this up for you anyway on exit from the app, so while it'd be good
practice to solve it, its not going to make any significance to any
application built on the OSG. Given how many other tasks I have on my
plate I'll leave this lower priority issue to others to chase up if
they fancy :-)
More information about the osg-users