Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-275

mariadb Connector/Python 1.1.8 has memory leak when using python 'with' statementfor connection

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Not a Bug
    • 1.1.8
    • N/A
    • Generic
    • Rocky8 x86_64
    • 3

    Description

      When called as follows, the mariadb-1.1.8 connector has a memory lead due to leaking connection and cursor objects:

      with mariadb.Connection( host='localhost',  user='root', password=db_pass, unix_socket=db_sock, connect_timeout=5 ) as db_conn:
          my_cur = db_conn.cursor()
          ...
      except mariadb.Error as ex:
          print(str(ex))
      

      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:
      memleak-with.py can be run (modify the db_pass to root password) to show the memory growth
      memleak-withfix.py contains a wrapper class which implements the _enter_ and _exit_ methods to close the connection and cursor, which does NOT have a memory leak.

      Attachments

        Activity

          People

            georg Georg Richter
            martin.reinhardt@mariadb.com Martin Reinhardt
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.