- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page