Questions about using TBB allocators

Questions about using TBB allocators

I've a lot of questions about using tbb allocators :

  1. When I include the file in a file of an DLL, I understand that all new/delete functions are replaced by the tbb allocators, isn't it ?
  2. Are allocators of std::set, std::list... are automatically replaced by the tbb allocators ?
  3. Or do I have to affect manually tbb_allocator for each STL containers ?
  4. If I include in an application, a DLL compile with tbbmalloc_proxy, are allocators used in the application are replaced by the tbb allocators ? I think Yes, if I include a DLL .h containing the tbbmalloc_proxy.h. But if any .h files of the DLL don't include the tbbmalloc_proxy ?
  5. Is it dangerous to include in an application, DLLs including tbbmalloc_proxy, with DLLs using default C++ allocators ?
  6. For a DLL, if I include the file in only one .cpp file, is all code of my DLL will be affected by the tbb allocators ?
2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

1. Only global new/delete operators are replaced. If new/delete is overloaded in some class, it's not replaced. Also please note that DLL with overload must be loaded during application startup.

2. If you use some custom STL allocators, they are not automatically replaced. Default allocators call global new, so TBB allocator would be used for such containers automatically.

3. Generally no, but you can look at cache_aligned_allocator if false sharing is a problem for a particular container usage.

4. Yes, but DLL must be loaded during application startup. There is nothing magic in tbbmalloc_proxy.h usage. You can use either include tbbmalloc_proxy.h or add tbbmalloc_proxy.lib /INCLUDE:"___TBB_malloc_proxy" to linker command line, result is the same.

5. No.

6. Yes, and even all the process wll use TBB allocator.

Leave a Comment

Please sign in to add a comment. Not a member? Join today