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

warning: leaked X task objects

mklvml
Beginner
400 Views
This warning seems undocumented. Could you explain its meaning?
0 Kudos
2 Replies
RafSchietekat
Valued Contributor III
400 Views
If you ask a question here, please make an effort and provide details even if you don't see whether they might be relevant.
0 Kudos
SergeyKostrov
Valued Contributor II
400 Views
>>...This warning seems undocumented. Could you explain its meaning?

There is a __TBB_COUNT_TASK_NODES macro. When the __TBB_COUNT_TASK_NODES macro is
defined a verification will be done to detect "Task Leaks".

In another words, it warns that some resources allocatedfor tasksare notreleaseddue to some reason.
A membermy_task_node_countshould be equal to zero if everithing was fine. If it is not zero a
'runtime_warning( ... )' method will becalled andthe warning messageis displayed.

Here is some summary from the TBB's sources:

market.h
...
#if __TBB_COUNT_TASK_NODES
//! Net number of nodes that have been allocated from heap.
/** Updated each time a scheduler or arena is destroyed. */
atomic my_task_node_count;
#endif /* __TBB_COUNT_TASK_NODES */
...
#if __TBB_COUNT_TASK_NODES
...
//! Net number of nodes that have been allocated from heap.
/** Updated each time a scheduler or arena is destroyed. */
void update_task_node_count( intptr_t delta )
{
my_task_node_count += delta;
}
#endif /* __TBB_COUNT_TASK_NODES */
...

market.cpp
...
void market::destroy()
{
#if __TBB_COUNT_TASK_NODES
if ( my_task_node_count )
runtime_warning( "Leaked %ld task objects\n", ( long )my_task_node_count );
#endif /* __TBB_COUNT_TASK_NODES */
this->~market();
NFS_Free( this );
__TBB_InitOnce::remove_ref();
}
...

scheduler.cpp
...
void generic_scheduler::free_scheduler()
{
...
#if __TBB_COUNT_TASK_NODES
my_market->update_task_node_count( my_task_node_count );
#endif /* __TBB_COUNT_TASK_NODES */
...
}
...

arena.cpp
...
void arena::free_arena()
{
...
#if __TBB_COUNT_TASK_NODES
my_market->update_task_node_count( -drained );
#endif /* __TBB_COUNT_TASK_NODES */
...
}
...

There is also a Test-Case at:

\Src\Test\test_task_leaks.cpp

0 Kudos
Reply