[CONPY-275] mariadb Connector/Python 1.1.8 has memory leak when using python 'with' statementfor connection Created: 2023-11-28 Updated: 2023-12-26 Resolved: 2023-12-12 |
|
| Status: | Closed |
| Project: | MariaDB Connector/Python |
| Component/s: | Generic |
| Affects Version/s: | 1.1.8 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Martin Reinhardt | Assignee: | Georg Richter |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | Connector | ||
| Environment: |
Rocky8 x86_64 |
||
| Attachments: |
|
| Python Version: | 3 |
| Description |
|
When called as follows, the mariadb-1.1.8 connector has a memory lead due to leaking connection and cursor objects:
Apparently the mariadb.Connection class does not handle (or properly) handle the special _enter_ and _exit_ methods to handle entry and exit from with statements. Attachments: |
| Comments |
| Comment by Georg Richter [ 2023-12-01 ] |
|
I don't think that closing the connection should also close the cursor. If a resource is not needed anymore, it should be closed immediately: Either by cursor.close() or using cursor context. See also: |
| Comment by Georg Richter [ 2023-12-12 ] |
|
The reason for the memory leak is not in MariaDB Connector/Python, but rather because the cursor was not closed properly. If the context is exited, only the connection itself is released, but not objects returned by the connection. This is not just the case in MariaDB Connector/Python, but in all modules. |