macOS* C/C++ Dynamic Memory Interface Replacement

Release version of the proxy library is libtbbmalloc_proxy.dylib, debug version libtbbmalloc_proxy_debug.dylib.

The following dynamic memory functions are replaced:

  • Standard C library functions: malloc, calloc, realloc, free

  • Standard POSIX* function: posix_memalign

  • Replaceable global C++ operators new and delete

  • Other functions: valloc, malloc_size

You can do the replacement either by loading the proxy library at program load time using the DYLD_INSERT_LIBRARIES environment variable (without changing the executable file), or by linking the main executable file with the proxy library.

The OS program loader must be able to find the proxy library and the scalable memory allocator library at program load time. For that you may include the directory containing the libraries in the DYLD_LIBRARY_PATH environment variable.


These examples show how to set DYLD_INSERT_LIBRARIES and how to link a program to use the memory allocation replacements.

# Set DYLD_INSERT_LIBRARIES to load the release version of the proxy library
# Link with the release version of the proxy library
clang++ foo.o bar.o -ltbbmalloc_proxy -o a.out

To use the debug version of the library, replace tbbmalloc_proxy with tbbmalloc_proxy_debug in the above examples.

For more complete information about compiler optimizations, see our Optimization Notice.