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

TBB Warning: Leaked 1 observer_proxy objects.

wzpstbb
Beginner
1,040 Views

Hi,

Recently I added my custom task scheduler observer. I got the following warning when debugging:

TBB Warning: Leaked 1 observer_proxy objects.

Does anyone know how to get rid of this warning?

My custom observer is pretty simple:

    class PipelineObserver : public tbb::task_scheduler_observer
    {
        ADrawContext& mDC;
        void operator=(const PipelineObserver&);
        PipelineObserver();
    public:
        PipelineObserver(ADrawContext& dc)
            : mDC(dc)
        {
            observe(true);
        }

        ~PipelineObserver()
        {
            observe(false);
        }

        virtual void on_scheduler_entry(bool  /* is_worker */ )
        {
            if(mDC.HasVirtualDevice())
                mDC.VirtualDevice().AcquireLocalOGLContext();
        }
    };

I used the observer as below:

                {
                    // Pipeline scheduler observer. It observes the worker threads entering the 
                    // task arena.
                    PipelineObserver o(dc);

                    // use TBB to execute a parallel while
                    tbb::parallel_while<ApplyIterator> w;
                    ApplyIterator body(*this, iteratorStream, eyePosition, maxCell, &w);
                    w.run(iteratorStream, body);
                }

Thanks!

0 Kudos
1 Solution
Kirill_R_Intel
Employee
1,040 Views

Hello,

First, the warning is not critical. Most likely the observer_proxy object is just destroyed later.

The warning may appear if TBB task scheduler is destroyed earlier than the observer object. It could happen if you explicitly created task_scheduler_observer in the same scope, though I don't see it in your code. If it is really important to avoid the warning, please attach the full code to reproduce the issue. 

View solution in original post

0 Kudos
2 Replies
Kirill_R_Intel
Employee
1,041 Views

Hello,

First, the warning is not critical. Most likely the observer_proxy object is just destroyed later.

The warning may appear if TBB task scheduler is destroyed earlier than the observer object. It could happen if you explicitly created task_scheduler_observer in the same scope, though I don't see it in your code. If it is really important to avoid the warning, please attach the full code to reproduce the issue. 

0 Kudos
wzpstbb
Beginner
1,040 Views

Thanks Kirill for the valuable clue. I have fixed this warning. 

0 Kudos
Reply