We have a piece of code that utilises TBB to spawn tasks to perform some processing this is done using the following TBB code to initialise the TBB thread pool (to match the number of cores):
tbb::task_scheduler_init(8);
Then for each task we want to spawn we use the following code (where MainTask is derived from the tbb::task class):
task = new (tbb::task::allocate_root()) MainTask(theAction, theOutputData);
tbb::task::enqueue(*task);
When we run our code we start off using a certain amount of memory and then as the program executes and spawns new tasks, as described above, the memory usage gradually increases over time. In 40 minute of execution it increases from from 12KB to 213KB. This is defiantly not as a result of any of our processing code and seems to be a result of TBB not freeing up the memory from the TBB allocate_root task that we are creating once they have completed their execution as we would expect it to.
Why is this happening? Is there something else we need to do to resolve this problem or is there some alternative way to spawn the TBB tasks without using the allocate_root approach that will resolve this problem?