[ODBC-33] Memory leak Created: 2016-03-30  Updated: 2016-04-01  Resolved: 2016-04-01

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: None
Affects Version/s: 1.0.5
Fix Version/s: 1.0.6

Type: Bug Priority: Major
Reporter: Sto Ges.m.b.H. Austria Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

Client: Windows Server 2012 R2, Server Fedora 17 with MySQL-Version 5.5.29


Attachments: File maodbc.dll     JPEG File maria_odbc-new_dll-01.jpg     JPEG File maria_odbc-new_dll-02.jpg     Text File maria_odbc.cpp     JPEG File test-mariadb_connector-01.jpg     JPEG File test-mariadb_connector-02.jpg     JPEG File test-myodbc-01.jpg     JPEG File test-myodbc-02.jpg    

 Description   

Tried to switch from MyODBC 3.51.11-2 (32bit) to MariaDB ODBC Connector 1.0.5 (64bit) and noticed a possible memory leak.

Server and client were the same in my tests, only the ODBC driver changed (and yes I compiled my source for 32bit and 64bit of course).

Source of my test program is attached. It just selects data from a table in a loop allocating and releasing the statement handle on every iteration. I did that to simulate my project which is a long running service with several allocs and releases of statement handles. (see attached source maria_odbc.cpp)

1st test was with the MariaDB ODBC connector. The program ran for about 27 minutes and the memory for the process increased from 1 MB to 8 MB during that period of time.
(see pics test-mariadb_connector-01.jpg and test-mariadb_connector-02.jpg)

2nd test was with the old MySQL 3.51 32 ODBC driver. After about the same period of time (but 50% more iterations - maybe performance is another issue but currently not mine the memory consumption of the process didn't increase (just a few bytes).
(see pics test-myodbc-01.jpg and test-myodbc-02.jpg)

With my current project the service used up about 3 GB of memory (starting from 1 MB) when running over the weekend. With the MyODBC 3.51 driver it stays at 1 MB for ages.



 Comments   
Comment by Lawrin Novitsky [ 2016-03-30 ]

Hello and thanks for your report. It so coincided, that one of last things I fixed in the connector, are several memory leaks
I am gonna attach dll file here, and I would appreciate if you checked your problem persists with this version.

As for connector being slower than 3.51 - could be expected. Your testcase does not use parameters. And 1.0.5 always uses prepared statements (for 'select' queries). On single use prepared statement will be slower. Plus 3.51 is ANSI driver, 1.0.5 is Unicode. Your testcase uses ANSI API, thus with 1.0.5 more ansi<->unicode recodings are involved.

Comment by Sto Ges.m.b.H. Austria [ 2016-03-31 ]

Wow, thanks for the quick response!

And excuse me if I ask a silly question now Tried to replace the DLL but can't add the datasource afterwards. It gives me "The setup routines for the MariaDB ODBC 1.0 Driver ODBC driver could not be loaded due to system error code 193."

If i try to add the DS using the old DLL (which of course works) and replace the DLL then, my program refuses to connect to the database.

Did I miss something here?

And thanks for the clarification on the performance. True and true The hands were quicker than the brain.

Comment by Lawrin Novitsky [ 2016-03-31 ]

Well, all you had to do is to overwrite old dll with with one. And all would work out of the box with old DSN/connection string. Setup dialog is in the separate and quite independent dll(maodbcs.dll). At least if it is invoked from the ODBC administrator, can be different with connect prompting.
So if you define new DS with old driver, and then overwrite maodbc.dll from that installation with the new file, it should work as well.

Not sure why it didn't work for you. I didn't notice anything wrong in your story.

As for performance - well, you do not have to know implementation details of myodbc 3.51 and maodbc 1.0

Comment by Sto Ges.m.b.H. Austria [ 2016-04-01 ]

Ever tried loading a 32bit DLL with your 64bit program :-D I did - doesn't work.

Now I compiled my program for 32 bit and installed the 32bit MariaDB Connector which I patched with the new DLL.

It (obviously!) works now and things improved a lot! After about 30 minutes (to be compareable with the previous tests) the memory consumption (1,2 MB) was only a bit over the initial value (0,9 MB). And I have to say that it rose to the 1,2 MB in the 1st minutes and stayed there for the rest of the time (actually I didn't stop it after I took the screenshot and it still says 1,2 MB).

See screenshots maria_odbc-new_dll-01.jpg and maria_odbc-new_dll-02.jpg

So from my point of view you did it! Thank you!

Comment by Lawrin Novitsky [ 2016-04-01 ]

Thank you for verifying that!
And sorry for giving 32bit dll, I did not pay attention to the fact that you use 64bit driver =)

I am gonna close the issue as fixed now.

Generated at Thu Feb 08 03:25:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.