Closed qwertyue closed 2 years ago
Can you include a complete, runnable script with the exact SQL statement? Also include the CREATE TABLE statement. Show us how you are measuring the memory use and what results you are seeing. Finally, what are the versions of cx_Oracle and of the Oracle client libraries used? You can get these by run the script shown in the issue template.
Can you include a complete, runnable script with the exact SQL statement? Also include the CREATE TABLE statement. Show us how you are measuring the memory use and what results you are seeing. Finally, what are the versions of cx_Oracle and of the Oracle client libraries used? You can get these by run the script shown in the issue template.
I will upload this information in a few hours But I may not be able to give you such information as exact SQL statement, CREATE TABLE statement. I passed memory_profile plug-in to prints the memory usage line by line I noticed that the fetchone function will use 0.3mb of memory each time it gets data, and will not release The fetchall function retrieves 50MB of data each time, and deleting the res reference will release 30MB
Finally, I will try the latest python oracle db
I assume that since you closed the issue the problem is resolved? What solved your problem?
I assume that since you closed the issue the problem is resolved? What solved your problem?
I ran the simulation code ( fetchone, and increase 0.1mb each time ) 2000 times, and the memory increased by 220MB.
Then gc.collect() was called manually, which reduced my memory by 160MB, only added 50MB.
So I don't think the memory leaked, And now I have a new question (sqlalchemy, cx_oracle and multithreading are used), which is OCI-21500: internal error code, arguments: [17099], [], [], [], [], [], [], []
If you are using multthreading, you need to ensure that the threaded
parameter is set to True
. This is done automatically in the new python-oracledb driver.
If you are using multthreading, you need to ensure that the
threaded
parameter is set toTrue
. This is done automatically in the new python-oracledb driver.
If I use sqlalchemy to connect oracle, the threaded
parameter in the python-oracledb driver will also be automatically set to True
?
Yes, take a look at the documentation to help during the transition. SQLAlchemy 2.0 (when it is released) will have native support for python-oracledb.
Yes, take a look at the documentation to help during the transition. SQLAlchemy 2.0 (when it is released) will have native support for python-oracledb.
Setting 'threaded' does not solve the problem of OCI-21500: internal error code, arguments: [17099], [], [], [], [], [], [], [].
Open a new issue, then, and give as much detail as you can -- including a runnable test case if at all possible!
OracleDB version 11.2.1
Python version 3.10
Code:
cursor = cx_Oracle.connection(conn_str)
use fetchone to get data
res = cursor.execute(select sql statment).fetchone() del res
cursor.close()
use fetchall to get data
Description: Even such simple code, it will leave the data returned by the fetchone(fetchone) function unable to be recycled, i even use gc.collection function. Or do I need to execute specific methods to prevent memory leaks?