SQLDriverConnect 期间的 MSSQL 内存泄漏问题(在 /usr/lib64/libodbc.so.2.0.0 中)

MSSQL memory leak issue during SQLDriverConnect (in /usr/lib64/libodbc.so.2.0.0)

我使用 valgrind 检查内存泄漏,我看到很多重复的消息,如下所示:

==29757== HEAP SUMMARY:
==29757== in use at exit: 62,472 bytes in 850 blocks
==29757== total heap usage: 7,597 allocs, 6,747 frees, 2,132,087 bytes allocated
    ==29757==
    ==29757== 1 bytes in 1 blocks are still reachable in loss record 1 of 767
    ==29757== at 0x4C29F73: malloc (vg_replace_malloc.c:309)
    ==29757== by 0x6020AF9: strdup (in /usr/lib64/libc-2.17.so)
    ==29757== by 0x5559B0F: ??? (in /usr/lib64/libodbc.so.2.0.0)
    ==29757== by 0x5559DF9: ??? (in /usr/lib64/libodbc.so.2.0.0)
    ==29757== by 0x551F0C2: SQLDriverConnect (in /usr/lib64/libodbc.so.2.0.0)
    ==29757== by 0x41125B: Database::init(std::string const&) 

    ==29757== 1 bytes in 1 blocks are still reachable in loss record 2 of 767
    ==29757== at 0x4C29F73: malloc (vg_replace_malloc.c:309)
    ==29757== by 0x6020AF9: strdup (in /usr/lib64/libc-2.17.so)
    ==29757== by 0x5559ABA: ??? (in /usr/lib64/libodbc.so.2.0.0)
    ==29757== by 0x5559DF9: ??? (in /usr/lib64/libodbc.so.2.0.0)
    ==29757== by 0x551F0C2: SQLDriverConnect (in /usr/lib64/libodbc.so.2.0.0)
    ==29757== by 0x41125B: Database::init(std::string const&) 

我也查了

https://github.com/Azure/unixODBC-MSSQL/blob/master/DriverManager/SQLDriverConnect.c

我不明白为什么 SQLDriverConnect 会导致内存泄漏

我想知道为什么我能看到这么多重复的消息。

这些报告显示内存仍然可用。对于许多程序来说,这样的 'still reachable' 内存不是问题,因为它们(故意)不会在退出前释放所有分配的内存,因为这将是无用的工作。

上面显示的 2 个报告非常相似,但被 valgrind 认为不同,因为堆栈跟踪略有不同:您有一个不同的程序计数器。