c++ - BOOST async_send_to 导致内存泄漏 (1.71)
问题描述
调用 sendSync 很好,调用 sendAsync 会导致堆上升。有没有人知道可能是什么原因以及如何解决它?
void sendAsync(const std::string& message)
{
socket.async_send_to(
boost::asio::buffer(message), remote_endpoint,
[this](boost::system::error_code /*ec*/, std::size_t /*bytes_sent*/)
{
});
}
void sendSync(const std::string& message)
{
boost::system::error_code ignored_error;
socket.send_to(boost::asio::buffer(message), remote_endpoint, 0, ignored_error);
}
for(;;)
{
TeleItems.SentCounter++;
printf("Sent Telegramm : %u \n",TeleItems.SentCounter);
sender.sendAsync( "Hi this is a telegramm" );
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
解决方案
推荐阅读
- flutter - Flutter pub 多次失败
- bash - 如果与 watch 命令一起使用,则在启动时运行脚本不起作用
- php - PHP Eclipse 安装报错
- c++ - 为什么包含 windows.h 会产生语法错误,从而阻止类的实例化?(C2146, C2065)
- java - 如何在 OpenJDK 11 中配置 Java 加密扩展 (JCE)
- python - 对象数组的 Python JSON 模式验证
- python - python中的eyed3 mp3元数据
- android - 如何使用 Moshi/Retrofit 反序列化原始 JSON 对象
- spring-boot - Spring Boot - 转换响应对象/json - 将对象的数组列表展平为 DAO
- python - 我需要在这里为 kwargs 赋予什么价值?