When running below sample unmanaged memory grows in module oci.dll, as soon as the OracleConnection itself is disposed it's freed again.
Do you know of any workarounds (besides disposing and creating a new connection) for this fix or is there any newer 7.* besides 7.9.333 that could work as well?
Code: Select all
internal class MemoryTestDevart
{
private const string SqlSpMemTest = "SP_MEM_TEST_TIMESTAMP";
private const string SqlSpMemTestParam = "P_CONTENT_DATETIMEOFFSET";
private const int StatementsPerLoop = 1000;
private const int Loops = 10000;
private const string ConnectionString =
"Data Source=YOURHOST;Persist Security Info=True;User ID=YOURUSER;Password=YOURPASS;Pooling=false";
private static void Main(string[] args)
{
using (OracleConnection connection = new OracleConnection(ConnectionString))
{
Console.Write("Start connect");
connection.Open();
for (int currentLoop = 0; currentLoop < Loops; currentLoop++)
{
OracleTimeStamp[] valuesDateTimeOffset = new OracleTimeStamp[StatementsPerLoop];
Parallel.For(0, StatementsPerLoop,
current => { valuesDateTimeOffset[current] = new OracleTimeStamp(DateTime.Now); });
Stopwatch stopExecution = Stopwatch.StartNew();
using (OracleTransaction transaction = connection.BeginTransaction())
{
using (OracleCommand executionCommand = new OracleCommand(SqlSpMemTest, connection))
{
executionCommand.Transaction = transaction;
executionCommand.CommandType = CommandType.StoredProcedure;
executionCommand.Parameters.Add(new OracleParameter(
SqlSpMemTestParam,
OracleDbType.TimeStamp,
valuesDateTimeOffset,
ParameterDirection.Input));
executionCommand.ExecuteArray(valuesDateTimeOffset.Length);
}
transaction.Commit();
}
stopExecution.Stop();
Console.WriteLine("Loop # {0} took {1} ms", currentLoop, stopExecution.ElapsedMilliseconds);
}
Console.WriteLine("Press enter to continue (it will dispose oracleConnection - memory should be freed)");
Console.ReadLine();
Console.WriteLine("Disposing connection");
}
Console.WriteLine("Check memory - it should be lower now");
Console.ReadLine();
}
}