tbb::concurrent_bounded_queue<T> memory allocation issues

tbb::concurrent_bounded_queue<T> memory allocation issues


I have a novice question concerning tb::concurrent_bounded_queue class.

While using it in the way shown below I notice that the memory used by the program increases over time!

Please advise me if I'm doing anything wrong:



   tbb::task_scheduler_init init(tbb::task_scheduler_init::automatic);

    typedef tbb::concurrent_bounded_queue<size_t> ConcurrentBoundedQueueType;
    ConcurrentBoundedQueueType _pcvMatBoundedQueue;

    size_t N = 10e+7;

    for (size_t j=0; j < 1000000; j++){
        std::cout << j << " :" << std::endl;

        std::cout << _pcvMatBoundedQueue.size() << " items exist" << std::endl;

        tbb::parallel_for<size_t>(0, N,[&](size_t i){

        std::cout << _pcvMatBoundedQueue.size() << " items exist" << std::endl;

        //tbb::parallel_for<size_t>(0,N,[&](size_t i){
        for(size_t i=0; i < N; ++i){
            size_t v=0;

        std::cout << _pcvMatBoundedQueue.size() << " items exist" << std::endl;

        std::cout << "is empty: " << _pcvMatBoundedQueue.empty() << std::endl;


2 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

Do any of those try_push() and try_pop() calls fail, or could you have put assertions there?

Do you see ever-increasing memory use, or does it plateau? Any numbers (level after first iteration, level of plateau, or memory consumption per iteration)?

What seems peculiar about the program is that the queue is filled in parallel, and emptied sequentially. Do you see any difference when trying any of the 3 other possible combinations?

I don't see anything problematic with the program, except perhaps "size_t N = 10e+7;" (it would never occur to me to assign an integer from a floating-point value (does that even work without a cast?), and the number is suspicious (why no 1e+8 instead, or did you really mean 10 to the 7th power?)), or the explicit task_scheduler_init (this has not been required anymore for quite a while now).

(Added 2013-11-22) Apparently (verified on a recent Clang compiler) one can initialise and assign a size_t from a non-integral double variable, an integral double literal, but not a non-integral double literal except with a cast. Where's the logic in that, and how is it even allowed (real questions)? And is there more information yet about the actual problem, perhaps confirmation of simple underestimation by a factor 10? :-)

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!