I will show a piece of code;
void wh(const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
std::cout << "test";
}
int main(int argc, char* argv[])
{
boost::asio::io_service pService;
boost::asio::serial_port pSerial(pService,"COM4");
while (true) {
boost::asio::async_write(pSerial, boost::asio::buffer("A",1),&wh);
}
return 0;
}
when I use this code, I get a memory leak, I found a piece of code such as a minicom_client tutorial, even the complex one from this code, also I get a memory leak on minicom_client. If i use
boost::asio::write(pSerial, boost::asio::buffer("A",1));
instead of async_write it works well, could you explain what is going on there, thanks a lot ...
source
share