libodbc++ - 内存泄漏

问题描述 投票:0回答:1

`我在与 libodbc++ 库 (0.2.5) 中的数据库创建每个连接时都面临内存泄漏。我在这里复制了 valgrind 日志。使用以下代码创建和删除连接。任何解决问题的建议。 libodbc++ 使用稳定吗?

示例代码:

`while(1)
{
    Connection* con = DriverManager::getConnection(ConnectionString);
    if(con != NULL)
    {
        delete con;
        con = NULL;
    }
}`

Valgrind 日志:

==7534== 283,173,984 (1,074,640 direct, 282,099,344 indirect) bytes in 9,595 blocks are definitely lost in loss record 7,279 of 7,279 ==7534== at 0x4CE9B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==7534== by 0x6FEB3B7: __gconv_open (gconv_open.c:74) ==7534== by 0x6FEB070: iconv_open (iconv_open.c:40) ==7534== by 0x3172BEB: unicode_setup (__info.c:601) ==7534== by 0x3136BD7: __SQLAllocHandle (SQLAllocHandle.c:492) ==7534== by 0x310DC4F: odbc::DriverManager::_createConnection() (drivermanager.cpp:140) ==7534== by 0x310DDBC: odbc::DriverManager::getConnection(std::__cxx11::basic_string<char,     std::char_traits\<char="">, std::allocator\<char> > const&, std::__cxx11::basic_string<char, std::char_traits\<char="">, std::allocator\<char> > const&, std::__cxx11::basic_string<char, std::char_traits\<char="">, std::allocator\<char> > const&) (drivermanager.cpp:183) ==7534== by 0x</char></char,></char></char,></char></char,>

我尝试过调试 libodbc++ 库。为每个连接正确调用 SQLAllocHandle 和 SQLFreeHandle,并且 SQLFreeHandle 返回 SQL_SUCCESS。 SQLFreeHandle 未释放内存。我没有遇到连接泄漏。 `

odbc unixodbc
1个回答
0
投票

我迟到了这个讨论,但 Linux 的 ODBC 框架中确实存在有关连接句柄的内存泄漏。我最终不得不创建一个脚本来时不时地终止我的应用程序以释放内存(幸运的是这并不重要)。 Linux 社区中似乎没有人对修复这个错误感兴趣,因为它已经存在了至少 15 年了。

© www.soinside.com 2019 - 2024. All rights reserved.