Connection pool is not getting cleared on AppDomain unload.
Posted: Tue 16 Oct 2012 08:45
Hi Team,
We found connection leak issue with the Devart when we use the connection in different AppDomain.
Scenario:
1. Create a console application which opens connection using Devart.
2. Create another console application with new AppDomain and from the new AppDomain try to execute the first console application
3. Here, the connection remains open even if we unload the newly created AppDomain.
4. We have verified this with V$session query.
ConsoleApplication1: Fire a select query using Devart.
private static void Main(string[] args)
{
Console.WriteLine(" Main in domain {0} called", AppDomain.CurrentDomain.FriendlyName);
String myConnString = "data source=orcl;user id=ABCD;password=ABCD;";
string mySelectQuery = "select * from TestDevart";
using (OracleConnection myConnection = new OracleConnection(myConnString)){
using (OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection)){
myConnection.Open();
using (OracleDataReader myReader = myCommand.ExecuteReader()){
while (myReader.Read()){
string testValue = myReader.GetString(myReader.GetOrdinal("TBLDESC"));}
myReader.Close(); } } }
Console.WriteLine("Query Fired..."); }
ConsoleApplication2: Create different AppDomain and execute the ConsoleApplication1.When we unload the newly created AppDomain, it should close the connection opened in ConsoleApplication1.
private static void Main(string[] args)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
Console.WriteLine("Original AppDomain: " + currentDomain.FriendlyName);
AppDomain secondDomain = AppDomain.CreateDomain("Second AppDomain");
secondDomain.ExecuteAssembly("ConsoleApplication1.exe");
AppDomain.Unload(secondDomain);
Console.WriteLine("Check the connection count");
Console.ReadLine();
}
Query to check the open connections:
select * from V$session where schemaname='xxx'
We found connection leak issue with the Devart when we use the connection in different AppDomain.
Scenario:
1. Create a console application which opens connection using Devart.
2. Create another console application with new AppDomain and from the new AppDomain try to execute the first console application
3. Here, the connection remains open even if we unload the newly created AppDomain.
4. We have verified this with V$session query.
ConsoleApplication1: Fire a select query using Devart.
private static void Main(string[] args)
{
Console.WriteLine(" Main in domain {0} called", AppDomain.CurrentDomain.FriendlyName);
String myConnString = "data source=orcl;user id=ABCD;password=ABCD;";
string mySelectQuery = "select * from TestDevart";
using (OracleConnection myConnection = new OracleConnection(myConnString)){
using (OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection)){
myConnection.Open();
using (OracleDataReader myReader = myCommand.ExecuteReader()){
while (myReader.Read()){
string testValue = myReader.GetString(myReader.GetOrdinal("TBLDESC"));}
myReader.Close(); } } }
Console.WriteLine("Query Fired..."); }
ConsoleApplication2: Create different AppDomain and execute the ConsoleApplication1.When we unload the newly created AppDomain, it should close the connection opened in ConsoleApplication1.
private static void Main(string[] args)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
Console.WriteLine("Original AppDomain: " + currentDomain.FriendlyName);
AppDomain secondDomain = AppDomain.CreateDomain("Second AppDomain");
secondDomain.ExecuteAssembly("ConsoleApplication1.exe");
AppDomain.Unload(secondDomain);
Console.WriteLine("Check the connection count");
Console.ReadLine();
}
Query to check the open connections:
select * from V$session where schemaname='xxx'