Some POSIX threads implementations (e.g. FreeBSD's libthr) allocate memory on the heap when pthread_cond_init() is called. Every call to that function must be accompanied by a corresponding call to pthread_cond_destroy() or else the memory allocated for the condition variable will leak. jemalloc can be used for detecting memory allocations which are not released by a process when it exits. Unfortunately, since jemalloc is also the system allocator on FreeBSD and a special (profiling-enabled) build of jemalloc is required for memory leak detection, this method cannot be used for detecting leaked memory allocated by libthr on a stock FreeBSD installation. However, libthr's behavior can be emulated on any platform by implementing alternative versions of libisc functions for creating and destroying condition variables that allocate memory using malloc() and release it using free(). This enables using jemalloc for detecting missing pthread_cond_destroy() calls on any platform on which it works reliably. When the newly introduced ISC_TRACK_PTHREADS_OBJECTS preprocessor macro is set, allocate isc_condition_t structures on the heap in isc_condition_init() and free them in isc_condition_destroy(). Reuse existing condition variable macros (after renaming them appropriately) for other operations.
-
-
-
-
-
-
-