Quite severe memory leak when using unicode = true
Posted: Fri 22 Jun 2007 11:10
When i execute this piece of code
OracleConnection oc = new OracleConnection();
oc.ConnectionString = "pooling = false";
oc.Unicode = true;
oc.AutoCommit = true;
oc.Server = "development";
oc.UserId = "user";
oc.Password = "pass";
oc.Open();
OracleCommand o2 = oc.CreateCommand();
o2.CommandType = CommandType.Text;
o2.CommandText = "drop table abc";
try
{ o2.ExecuteNonQuery(); }
catch
{}
o2.CommandText = "create table abc (a varchar2(4000))";
o2.ExecuteNonQuery();
o2.CommandText = "select a from abc where 1 = -1";
for (int i = 0; i < 10000; i++)
{
OracleDataReader or = o2.ExecuteReader();
or.Read();
or.Close();
or.Dispose();
or = null;
}
o2.Dispose();
o2 = null;
oc.Close();
oc.Dispose();
oc = null;
GC.Collect();
Memory usage starts at say around 30mb and gradually rises to around 300mb.
As you can see the query doesnt even return any rows, and the amount of memory used appears to increase/decrease depending on the size of the varchar field that I create.
This does not happen with unicode = false.
OracleConnection oc = new OracleConnection();
oc.ConnectionString = "pooling = false";
oc.Unicode = true;
oc.AutoCommit = true;
oc.Server = "development";
oc.UserId = "user";
oc.Password = "pass";
oc.Open();
OracleCommand o2 = oc.CreateCommand();
o2.CommandType = CommandType.Text;
o2.CommandText = "drop table abc";
try
{ o2.ExecuteNonQuery(); }
catch
{}
o2.CommandText = "create table abc (a varchar2(4000))";
o2.ExecuteNonQuery();
o2.CommandText = "select a from abc where 1 = -1";
for (int i = 0; i < 10000; i++)
{
OracleDataReader or = o2.ExecuteReader();
or.Read();
or.Close();
or.Dispose();
or = null;
}
o2.Dispose();
o2 = null;
oc.Close();
oc.Dispose();
oc = null;
GC.Collect();
Memory usage starts at say around 30mb and gradually rises to around 300mb.
As you can see the query doesnt even return any rows, and the amount of memory used appears to increase/decrease depending on the size of the varchar field that I create.
This does not happen with unicode = false.