oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
890 stars 361 forks source link

Possible memory leak when using rowfactory #623

Closed robingie closed 1 year ago

robingie commented 2 years ago
  1. OracleDB version Oracle 11.2.1

  2. Commands

    • print("sys.maxsize > 232:", sys.maxsize > 232) True
    • print("platform.platform:", platform.platform()) platform.platform: Linux-4.18.0-348.7.1.el8_5.x86_64-x86_64-with-glibc2.28
    • print("platform.python_version:", platform.python_version()) platform.python_version: 3.9.6
    • print("cx_Oracle.version:", cx_Oracle.version) cx_Oracle.version: 8.3.0
    • print("cx_Oracle.clientversion:", cx_Oracle.clientversion()) cx_Oracle.clientversion: (19, 6, 0, 0, 0)
  3. Is it an error or a hang or a crash? Hang because the system can run out of memory.

  4. What error(s) or behavior you are seeing? The Python application grows in memory size after a while. Each time a new cursor is created and the cursor.rowfactory is used, the memory requirement increases.

  5. Include a runnable Python script that shows the problem.

    with conn.cursor() as cur:
        cur.execute(query2, start_id=start_id)
    
        # This line causes a growing memory footprint
        cur.rowfactory = lambda *args: dict(zip([d[0] for d in cur.description], args))
    
        # This line avoids the memory leak
        data = [dict((cur.description[i][0], value) for i, value in enumerate(row)) for row in cur.fetchall()]

image

lime-n commented 1 year ago

I too have been having the same issue when running this. I have experienced black-screen as well as blue-screen because of the growing memory size.

What's the progress on this?

sharadraju commented 1 year ago

@lime-n Please upgrade cx_Oracle to the new version, now called python-oracledb, see the release announcement and run your test case. If this issue still persists, please provide us a runnable test case with the complete platform details as shown in the initial comment of this bug.

lime-n commented 1 year ago

Hi @sharadraju,

I have been using python-oracledb and this issue will regardlessly persist. When I have some time, I'll upload a reproducible example.

stale[bot] commented 1 year ago

This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically closed because it has not been updated for a month.