-
Notifications
You must be signed in to change notification settings - Fork 467
Closed
Description
I am trying to use asio::thread_pool for general computation, and though I am finding a really nice speedup, I am also finding that it uses large amounts of memory dependent of number of tasks dispatched.
#include <iostream>
#include <vector>
#include <boost/asio/thread_pool.hpp>
#include <boost/asio/dispatch.hpp>
using namespace std;
boost::asio::thread_pool t_pool(4);
int main() {
for (int run = 0; run < 100'000; run++) {
boost::asio::dispatch(t_pool,
[] () {}
);
t_pool.join();
}
}
Here time -v tells me Maximum resident set size (kbytes): 4264. If I increase the number of loops to 1000000: for (int run = 0; run < 1'000'000; run++) then time -v repots Maximum resident set size (kbytes): 32812. As you can see the tasks dispatched do absolutely nothing and they are waited for by the end of each loop. Naively I would think that no memory associated with the previous task should remain when the next loop starts.
Metadata
Metadata
Assignees
Labels
No labels