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

question about memory leak by using pipeline

Yuan_Y_1
Beginner
468 Views

when I initial like this: tbb::task_scheduler_init parallel, the program has memory leak, but when I set it as: task_scheduler_init init(1), there is no memory leak. 

I want to know the reason.

ps: the visual leak detector(VLD) can't detect the memory leak. but I run the program in a loop, and the same time monitor the memory usage delta, indeed the memory leak.

0 Kudos
2 Replies
Alexei_K_Intel
Employee
468 Views

Hi,

It is not clear from your description what causes the leak. What TBB algorithms and data structures do you use? What is the TBB version? Do you observe the constant delta or is it increasing over the time? Does the delta depend on the number of iterations in the loop? What is the approximate algorithm structure? Could you provide a reproducer? Could you provide some information that you think can help us to troubleshot the issue, please?

Thank you in advance.

Regards, Alex

0 Kudos
Yuan_Y_1
Beginner
468 Views

Thanks for reply.

The TBB version is 41 and the algorithms is pipeline class, we use Visual Studio 2010. Today, I find the example of pipeline which providing by TBB also have memory leak. Maybe the reason is that when we use the pipeline with parallel mode, we use task_scheduler_init class to create some threads, and threads are not destroyed.  

I will use the square.cpp(TBB provided in /example/pipeline)as example to show the memory leak.

            { // serial run
                if ( !silent ) printf("serial run   ");
                tbb::task_scheduler_init init_serial(1);
                if(!run_pipeline (1))
                    return 1;
            }
            { // parallel run (number of threads is selected automatically)
                if ( !silent ) printf("parallel run ");
                tbb::task_scheduler_init init_parallel;
                if(!run_pipeline (init_parallel.default_num_threads()))
                    return 1;
            }

if the "parallel run" was executed,  the leak will be happened, it's ok for "serial run".  The output memory leaks as shown in the figure.

memory leak.png

Maybe I use the pipeline class in a wrong way. In my program, I initial the TBB every time in one loop, so I see the memory increasing  slowly over the time.

0 Kudos
Reply