boost::asio::streambuf b;
...
void handler(const boost::system::error_code& e, std::size_t size)
{
if (!e)
{
std::stringstream sstr(std::string((std::istreambuf_iterator<char>(&b)),
std::istreambuf_iterator<char>()));
b.consume(size);
...
}
}
...
boost::asio::async_read_until(s, b, "END\r\n", handler);
when the consume
method is called, the memory occupied by streambuf b
is not released. The memory will grow up as async_read_until
is called multiple times. Is my usage correct? Is there any way to free the memory before the get pointer
of streambuf?