内存泄漏使用boost::存档::binary_iarchive
Memory Leak using boost::archive::binary_iarchive
反序列化正在工作,问题是内存泄漏。 我已经尝试删除"s"指针,但出现"定位失败",我无法删除指针。
//Statment MySql
sql::Statement *_stmt = this->con->createStatement();
sql::ResultSet *_result = _stmt->executeQuery("SELECT * FROM matches ORDER BY `match_seq_num` ASC LIMIT 1250");
while(_result->next()){
std::istream *s = _result->getBlob("match_object");
boost::archive::binary_iarchive ia(*s);
Match _match;
ia >> _match;
delete s;
}
delete _result;
delete _stmt;
问题是在使用boost::archive::binary_iarchive ia(*s);
反序列化来自 mysql 的信息后删除"s"指针。
当然,您需要删除。
如果这会带来问题,您应该修复它。您的更新指向一个可能的罪魁祸首:输入存档引用istream
并且仍然可以在析构函数中访问它(事实上我认为它很可能确实如此(。因此,请确保在销毁所需资源之前它已消失:
//Statment MySql
sql::Statement *_stmt = this->con->createStatement();
sql::ResultSet *_result = _stmt->executeQuery("SELECT * FROM matches ORDER BY `match_seq_num` ASC LIMIT 1250");
while(_result->next()){
Match _match;
{
std::istream *s = _result->getBlob("match_object");
{
boost::archive::binary_iarchive ia(*s);
ia >> _match;
}
delete s;
}
}
delete _result;
delete _stmt;
相关文章:
- LeetCode 1011.Binary Search,C++和Python的想法相同,但输出不同
- 删除提升存档对象也会删除与其关联的流?
- 提示存档文件中的动态库依赖项
- 如何在 c++ 中打印存档中的对象向量
- 需要从存档中读取一行文本.txt直到找到"hhh",然后转到下一行
- 在现代 CMake 项目中存档静态依赖项
- 如何将空文件夹和符号链接添加到存档 - libarchive
- 从Qt QJsonDocument::toBinaryData使用non-Qt读取Binary Json?
- 收获(加热) Wix - 在 MSI 中存档资源
- GCC:--静态链接到pthread的整个存档配方在最近的GCC版本中停止工作
- 增强序列化,按基类型加载存档类会产生错误的数据
- 增强二进制存档 - 减小大小
- 如何使用curl c ++源代码发布wav文件数据,如何使用c ++使用--data-binary?
- 连接存档加速序列化
- 内存泄漏使用boost::存档::binary_iarchive
- 用ar编译的存档,手动编译,ld找不到
- CMake 错误: "add_subdirectory not given a binary directory"
- 为什么直接传递"this"指针来存档是一个错误,而另一个相同类型的指针是可以的?
- 使用原始字节向量作为提升序列化的存档的任何方法
- 如何在Boost Serialization ::存档中抑制额外信息