Community
cancel
Showing results for 
Search instead for 
Did you mean: 
iupright
Beginner
102 Views

using task_list with TBB, memory leak?

Lets say I have some example code:

task_list myTaskList;
for (itr = parallelOperators.begin(); itr != parallelOperators.end(); itr++ ) {
MYParallelOperator* eachOperator = *itr;
MYParallelTask& newTask = *new( task::allocate_root() ) MYParallelTask( eachOperator );
myTaskList.push_back( newTask );
}
task::spawn_root_and_wait( myTaskList );

My tasks don't spawn any children.. it's all very simple. The above code/patternappears to be working perfectly for me. Is there anything wrong with this approach? The problem I'm having is that it seems like the tasks or resources aren't being destroyed properly.. because it appears that I'm leaking some memory somewhere here. (valgrind tells me so)

First of all, is the above pattern correct?

Thanks, Ian

0 Kudos
3 Replies
ARCH_R_Intel
Employee
102 Views

Yes, the pattern is correct.

The TBB implementation does keep an internal free list of former task objects that it recycles. Those lists are freed after the task scheduler terminates (typicalliy when the last task_scheduler_init object is destroyed). Perhaps Valgrind is not accounting for the free list?

iupright
Beginner
102 Views

When i call this in a loop over and over, using the same task scheduler,sure it might create some tasks, and then recycle them later.. but in this particular example I have the exact same number of tasks created in each run. Thus, if they are truly getting recycled, it should not continually be growing, and endlessly and leaking memory.

So is this a bug.. or is there something I'm supposed to be doing to clean up the resources?

Ian

ARCH_R_Intel
Employee
102 Views

You should nothave to do anything special to clean up the resources. Can you send a small self-contained example that exhibits the problem?
Reply