My apparent memory leak from the other day did in fact turn out to be leaking thread resources. The key: Don't Join on Yourself!
If a thread attempts to call pthread_join on itself it is likely to cause a deadlock in that thread that you may never know about. Particularly if you are using some sort of worker-thread model that creates and destroys threads often.
A simple way to catch this problem would be to add an assertion in your destructor.
class threaded_class { ~threaded_class() { // if somehow this thread tries to join on itself, perhaps by causing this // instance of threaded_class to get destroyed, cause an assertion failure // so we can investigate it assert(!pthread_equal(m_worker_thread, pthread_self())); pthread_join(m_worker_pthread); } pthread_t m_worker_thread; };
Recent comments
17 hours 23 min ago
22 hours 27 min ago
22 hours 56 min ago
1 day 15 hours ago
1 day 22 hours ago
1 week 6 days ago
3 weeks 16 hours ago
3 weeks 1 day ago
3 weeks 3 days ago
3 weeks 4 days ago