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

libtbb new/delete

Penunuri__David
Beginner
482 Views

I am trying to parallelize an application that uses new/delete from the standard libraries to allocate/deallocate memory.  In my code I replaced a traditional for loop with the parallel_for template.  When the execution reaches the parallel_for and a few threads are running my application crashes.  The error messages suggest a problem with memory allocation/deallocation.  I have used libtbb.so and libtbbmalloc.so. but it still crashes.  I tried to use libtbbmalloc_proxy.so but the program will not link.  Says it cannot find libtbbmalloc_proxy.so.2 even though it is in the same folder as the other libraries.

The problem seems to be a conflict in memory allocation.  I am adding my code to a commercial application so I cannot rebuild the whole application.  Any suggestions on how solve?

0 Kudos
3 Replies
Alexei_K_Intel
Employee
482 Views

Usually, there is no limitations with new/delete inside parallel_loop. The observed issue might relate to some data races or double free problems. Could you describe how you replaced the serial loop with parallel_for, please? Did you use lambda interface?

0 Kudos
Nikita_P_Intel
Employee
482 Views

Hi David,

You can use LD_PRELOAD=$LIB_PATH/libtbbmalloc_proxy.so.2 to make sure, that your application uses tbbmalloc routines. If the crash still happens, could you please send an error log.

Nikita

0 Kudos
Akbarzadeh__Afshin
482 Views

I have the same problem in my codes.

I have bunch of functions running with TBB parallel for loop. In each one of I use some local STL containers. When I run the app, it the beginning it is OK but after a while the application crashes. The thrown exception says it might be double deleting of STL container.
The problem is random but it is all about deleting one of STL containers.
I am sure that I've set up the code to use tbb scalable allocator but the problem still holds

0 Kudos
Reply