Community
cancel
Showing results for 
Search instead for 
Did you mean: 
mem64k
Beginner
90 Views

TBB memory leaks when using inside of MFC application

Hello tbb-users / tbb-devs,

Operation system: Windows 7 x64 SP1; TBB version: 4.2.0; Compiler: Visual Studio 2012.

Problem description:

TBB dumps memory leaks on the exit of MFC application. The same code doesn't dump any leaks, when used from simple command line program. It looks like a DLL unload order problem. Due to late tbb.dll unloading the debuger dumps some static variables as leaks.

Can someone confirm this issue? Is there any work around?

Attached to this post you will find the both test applications: command line and MFC.

Here is the memory dump:

Detected memory leaks!
Dumping objects ->
{608} normal block at 0x00457970, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{607} normal block at 0x00457918, 28 bytes long.
 Data: <    pyE         > 00 00 00 00 70 79 45 00 98 0F 00 00 00 00 00 00
{605} normal block at 0x0044ED98, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{590} normal block at 0x00450AD8, 28 bytes long.
 Data: <      D         > 00 00 00 00 98 ED 44 00 04 20 00 00 00 00 00 00
{583} normal block at 0x00455AD8, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{582} normal block at 0x00455A80, 28 bytes long.
 Data: <     ZE  .      > 00 00 00 00 D8 5A 45 00 98 2E 00 00 00 00 00 00
{580} normal block at 0x00455860, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{579} normal block at 0x00455808, 28 bytes long.
 Data: <    `XE         > 00 00 00 00 60 58 45 00 EC 18 00 00 00 00 00 00
{569} normal block at 0x00453EC8, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{568} normal block at 0x00453E70, 28 bytes long.
 Data: <     >E  0      > 00 00 00 00 C8 3E 45 00 FC 30 00 00 00 00 00 00
{566} normal block at 0x00453C50, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{565} normal block at 0x0044D338, 28 bytes long.
 Data: <    P<E         > 00 00 00 00 50 3C 45 00 D8 08 00 00 00 00 00 00
{546} normal block at 0x0044F248, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{536} normal block at 0x00451128, 28 bytes long.
 Data: <    H D  !      > 00 00 00 00 48 F2 44 00 14 21 00 00 00 00 00 00
{531} normal block at 0x00450518, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{530} normal block at 0x004504C0, 28 bytes long.
 Data: <      E T!      > 00 00 00 00 18 05 45 00 54 21 00 00 00 00 00 00
{528} normal block at 0x00450290, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{527} normal block at 0x00450238, 28 bytes long.
 Data: <      E 8       > 00 00 00 00 90 02 45 00 38 18 00 00 00 00 00 00
{518} normal block at 0x0044EE68, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{517} normal block at 0x0044EE10, 28 bytes long.
 Data: <    h D  2      > 00 00 00 00 68 EE 44 00 B0 32 00 00 00 00 00 00
{507} normal block at 0x0044B190, 36 bytes long.
 Data: <T B B   W o r k > 54 00 42 00 42 00 20 00 57 00 6F 00 72 00 6B 00
{505} normal block at 0x0044D3B0, 28 bytes long.
 Data: <      D  '      > 00 00 00 00 90 B1 44 00 18 27 00 00 00 00 00 00
Object dump complete.
The program '[12168] TbbMfcTest.exe: Native' has exited with code 0 (0x0).

0 Kudos
3 Replies
90 Views

hello,

TBB workers are detached and shut themselves down after dll unloaded. Why do you think that this is a problem during application shutdown? Are there any resource leaks in the system due to this?

--Vladimir

mem64k
Beginner
90 Views

Hello Vladimir,

in case there are no real memory leaks there surelly no problem for the application shutdown. But it is very confusing if the debugger floods you with memory leaks and you need always verify if those are real or not and if those are from TBB!

Can you confirm that the memory leaks are due to late DLL unloading?

gast128
Beginner
90 Views

See also stackoverflow: 'tbb-memory-leaks-when-using-inside-of-mfc-application'

TBB leaks 2 memory allocations in __itt_thread_info structure: the structure itself is not released properly and the allocated name ("TBB Worker Thread") is also not released. See the market::create_one_job() function. Although the leaks are small and not accumulating, they result in dump reports in the output window in Visual Studio which we like to keep clean. Therefore we had to work around this problem, but I suppose 2 extra 'free' calls are already sufficient to resolve the problem. It would help us a lot.

Reply