Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2412 Discussions

Memory leaks in ITT included with TBB 4.4 U2


Hi! In TBB 4.4 U2, the version of ITT included (in the tools_api folder) will leak two small chunks of memory for every worker thread created.

The following simple call is enough to reproduce the leaks (tested on x64 build using VS2015 Update 1) :

tbb::parallel_invoke([] {}, [] {});

(To avoid false positives due to process exit before worker threads are shutdown, we should use tbb::task_scheduler_init and TBB_PREVIEW_WAITING_FOR_WORKERS.)

The leaks in ITT happen when market::create_one_job() calls thread_set_name (via macros). The latter function is implemented in tools_api/ittnotify_static.c and leaks twice for each call:

* Each itt_thread_info node on the global .thread_list is malloc'ed via NEW_THREAD_INFO() but never freed.

* The name member inside each itt_thread_info node is malloc'ed via strdup / wcsdup but never freed.

This should be high prio since it may produce a large number of memory leaks from TBB, making it hard to locate other mem-leaks in client code.

A possible workaround is to rebuild tbb_debug.dll + .lib with DO_ITT_NOTIFY undefined.

Here is a complete example to reproduce the leaks:

#include <windows.h>
#include <tchar.h>
#include <assert.h>

#include "tbb/parallel_invoke.h"
#include "tbb/task_scheduler_init.h"
#include "tbb/tbb_allocator.h"

int _tmain(int argc, _TCHAR* argv[])
  assert(tbb::tbb_allocator<int>::allocator_type() != tbb::tbb_allocator<int>::scalable);

    tbb::task_scheduler_init scope(tbb::task_scheduler_init::automatic, 0, true);
    tbb::parallel_invoke([] {}, [] {});

  return 0;


Göran Wallgren

0 Kudos
1 Reply

Thanks for digging into this.

we are looking for a fix.