Bug #106886 | ODBC driver memory leak | ||
---|---|---|---|
Submitted: | 1 Apr 2022 9:00 | Modified: | 9 Jun 2022 21:40 |
Reporter: | c t | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / ODBC | Severity: | S3 (Non-critical) |
Version: | 8.0.28 | OS: | Windows (Windows 10 Enterprise Edition 64Bit ) |
Assigned to: | CPU Architecture: | Any | |
Tags: | ODBC 8 |
[1 Apr 2022 9:00]
c t
[4 Apr 2022 7:02]
Bogdan Degtyariov
Verified with the version 8.0.29. Each new Connect/Disconnect cycle adds to the working set size about 0x1000. This can only be observed when on each iteration ENV handle is allocated/freed. If ENV is allocated once and reused for each new connection the working set size stabilizes after a few iterations.
[4 Apr 2022 8:46]
c t
verified, holding ENV handle alive will cause no memory leak. after ~15 iteration. result of keeping ENV alive is that the driver is not unloaded, thus not loaded anymore and therefore not allocating (additional) memory. possible WorkAround is clear: keeping ENV handle somehow statically, for ex. as singleton and reuse when creating connections). unfortunately we have a wrapper class for the whole ODBC DB access, this includes also SQLAllocHandle/SQLFreeHandle the ENV handle. (very old legacy code) will there be a fix for the memory consumption in case SQLAllocHandle/SQLFreeHandle for ENV is allocated each time a connection is created?
[17 May 2022 12:25]
Bogdan Degtyariov
Posted by developer: The memory leak was caused by wrong initialization counter, which did not allow calling of mysql_library_end() upon DLL_PROCESS_DETACH event.
[18 May 2022 10:44]
Bogdan Degtyariov
Posted by developer: The fix for the problem with mysqlclient library uninitialization is pushed to the source tree.
[18 May 2022 12:02]
Bogdan Degtyariov
Posted by developer: Another problem spotted when investigating this bug. It was reported as a separate ticket and will have a separate fix: https://bugs.mysql.com/bug.php?id=107328
[9 Jun 2022 21:40]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Connector/ODBC 8.0.30 release, and here's the proposed changelog entry from the documentation team: Fixed memory leak caused by ODBC data source reconnects; now mysql_library_end() is called upon the DLL_PROCESS_DETCH event. The workaround is to reuse ENV for each new connection. Thank you for the bug report.