Hello, i had a headache for a few days with my app. The number of threads and memory grew to infinity with pooling=false. When i turned on pooling with Max Pool Size=10 i saw in Performance monitor that pooled connections also grew (70 and more) until max sessions per user were reached and every other attempt to call OracleConnection.Open() ended with an error. Then i finally found that this crazy behavior was due to using this constructor:
new OracleConnection(string connectionString, OracleCredential credential)
It seemed safer to me to remove credentials from the connection string and use the class OracleCredential. So when i returned to the constructor only with the ConnectionString (with credentials inside it) the problems with memory and threads were gone.
Here is the code to reproduce this issue:
while (true)
{
string name="myname";
var password = new SecureString();
foreach (char item in "mypassword")
{
password.AppendChar(item);
}
password.MakeReadOnly();
OracleCredential oracleCredential = new(name, password);
string connectionString="Data Source = (DESCRIPTION=(SDU=1024)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.x)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=mySN)));pooling=false";
OracleConnection conn=new(connectionString, oracleCredential);
conn.Open();
conn.Close();
conn.Dispose();
// looks like the Dispose does not release OracleConnection object from memory
Thread.Sleep(1000);
}
Versions:
Windows 10
Oracle.ManagedDataAccess.Core 23.4.0 - 23.9.1
64 bit console app
.NET8 - .NET9
Update:
After reading this i found that i can avoid the problem by reusing the same OracleCredential object in all OracleConnection instances. But i think if my problem is not a bug it should be better documented here and here.