Git Product home page Git Product logo

Comments (7)

FelixPetriconi avatar FelixPetriconi commented on July 19, 2024 1

This is not the leak. Later on the callback_impl the passed parameter is taken as unique_ptr and so the object is deleted after leaving the function. What I could imagine, that the thread pool object must be cleaned somehow. But I will check that tomorrow.

from libraries.

FelixPetriconi avatar FelixPetriconi commented on July 19, 2024 1

I forwarded the question to Sean and he replied: "The idea with the channels is if you have a generator to construct it as a coroutines in the channel- then you have flow control. Blocking on send() means you have a requirement for “at least one additional thread”, with no upper bound in general. send() is just there to prime the pump."
So in other words, you have to control the values, that you send into your channel.

from libraries.

FelixPetriconi avatar FelixPetriconi commented on July 19, 2024

Hi,
many thanks for reporting this. I will look into it as soon as I can and we will provide a fix in the next release,
Regards, Felix

from libraries.

FelikZ avatar FelikZ commented on July 19, 2024

@FelixPetriconi thanks for a quick response!

I have found a root-cause, it's this:
https://github.com/stlab/libraries/blob/develop/stlab/concurrency/default_executor.hpp#L165

    template <typename F>
    void operator()(F&& f) {
        auto work = CreateThreadpoolWork(&callback_impl<F>,
            new F(std::forward<F>(f)), // here we allocate memory that is not cleaned
            &_callBackEnvironment);

        if (work == nullptr) {
            throw std::bad_alloc();
        }
        SubmitThreadpoolWork(work);
    }

Not sure what todo about it, since CreateThreadpoolWork always wants a pointer and we do not know when work is done to clean memory.

from libraries.

FelixPetriconi avatar FelixPetriconi commented on July 19, 2024

As far as I can see, there is no memory leak in the channel library. I wrote small test program and I checked it with the Intel Memory Leak analyzer.
I can see, that the internal queue, a deque, of the channel increases, because it get the values faster, than they could be processed downstream by the attached receiver. So far there is no mechanism to shrink this deque. There is a mechanism in the channel, that allows to limit this queue size. One has to combine a process with a stlab::buffer_size(value). But this helps only half way, because the sender itself has a queue as well and that cannot be limited so far. We will discuss internally, how we can improve this.
I see a similar behavior when I use the STLAB_TASK_SYSTEM_PORTABLE.

from libraries.

FelikZ avatar FelikZ commented on July 19, 2024

@FelixPetriconi thanks for investigation, indeed I saw memory problems with portable version too. But compare to windows version, it is possible to control memory (for my app type) by using thread sleeps, so that queue can actually be dequed.

However, this tactics does not help to windows version and it leaks a lot of memory regardless of deque.

And it depends on an object size that you send into a channel, that's why I am not sure that its cleaned well.

We will discuss internally, how we can improve this.

Thanks, looking forward to it!

from libraries.

FelikZ avatar FelikZ commented on July 19, 2024

@FelixPetriconi hi, any news on it?

from libraries.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.