Comments (7)
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.
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.
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.
@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.
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.
@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.
@FelixPetriconi hi, any news on it?
from libraries.
Related Issues (20)
- Version in CMakeLists.txt is not correct
- Some files are missing in ./stlab/CMakeLists.txt HOT 1
- Build Error for Portable Executor for c++14 HOT 1
- Executor of packaged_task not used in reduction HOT 7
- Extra Copy of Object in Future Somewhere
- wasm main executor object not defined
- Upgrade to 1.7.1 now requires Qt and Boost HOT 20
- Is documentation generation broken? HOT 12
- No build output HOT 2
- Generated config.hpp Disables Ability to Use Same Source For Multiple Platforms HOT 1
- main_executor_type lost in main_executor.hpp for EMSCRIPTEN HOT 1
- Problem with main_executor for Qt on application exit HOT 3
- WASM main_executor improvements
- Broken compatibility with Qt5 HOT 1
- Handling more then one priority_task_system instance HOT 6
- stlab documentation, best practice and performance HOT 3
- Express the type of `promise` HOT 3
- windows default executor is not exception safe.
- Add weak_future<>
- Update range based algorithms
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libraries.