Question around boost.threads

Hello. I'm using boost.thread as static library and it seems there is a resource leak here. Please explain me setting of tss_hook and other tss_* files. I think it helps me to check if my assumptions are correct. File tss_hooks.cpp contains the following code: // ... // because we cannot delete it again easily. CRITICAL_SECTION threadmon_mutex; void init_threadmon_mutex(void) { //threadmon_mutex = new boost::mutex; //if (!threadmon_mutex) // throw boost::thread_resource_error(); ::InitializeCriticalSection(&threadmon_mutex); } // ... But I didn't find any place where library calls DeleteCriticalSection for threadmon_mutex. Is it resource leak or its my misundertanding? Thank you. -- Best Regards, Dmitriy Lyfar

Dmitri Lyfar <dlyfar@gmail.com> writes:
Hello. I'm using boost.thread as static library and it seems there is a resource leak here. Please explain me setting of tss_hook and other tss_* files. I think it helps me to check if my assumptions are correct. File tss_hooks.cpp contains the following code: // ... // because we cannot delete it again easily. CRITICAL_SECTION threadmon_mutex; void init_threadmon_mutex(void) { //threadmon_mutex = new boost::mutex; //if (!threadmon_mutex) // throw boost::thread_resource_error(); ::InitializeCriticalSection(&threadmon_mutex); } // ... But I didn't find any place where library calls DeleteCriticalSection for threadmon_mutex. Is it resource leak or its my misundertanding? Thank you.
It is hard to find a reliable point when deleting the critical section is safe, and nothing will try and access it later. Therefore it is not done. Technically this is a resource leak, but Windows will clean up properly when the application exits, so this is not a problem. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
participants (2)
-
Anthony Williams
-
Dmitri Lyfar