dotConnect for Oracle. Memory Leak

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
amirela
Posts: 15
Joined: Tue 26 Oct 2010 10:51

dotConnect for Oracle. Memory Leak

Post by amirela » Fri 12 Apr 2013 11:17

if Oracle connection is invalid (e.g. Data Source property is incorrect), the code below causes memory leaks:

Code: Select all

while (true)
{
   OracleConnection connection = null;
   try
   {
      connection =
         new OracleConnection(
            "Data Source=myOracle;User ID=aaa;Password=aaa;Pooling=true;Validate Connection=True;Max Pool Size=10;Connection Timeout=5;");
      //connection.Open();

      var result = connection.BeginOpen(null, null);
      if (WaitHandle.WaitAny(new[] {result.AsyncWaitHandle},
                           connection.ConnectionTimeout > 0 ? connection.ConnectionTimeout*1000 : -1) ==
         WaitHandle.WaitTimeout)
      {
         connection.Close();
         throw new TimeoutException("Timeout");
      }
      connection.EndOpen(result);
   }
   catch (Exception ex)
   {
      ;
   }
   finally
   {
      if (connection != null)
      {
         connection.Close();
         connection.Dispose();
         connection = null;
      }
   }
}
But if i use "connection.Open();" All's OK

amirela
Posts: 15
Joined: Tue 26 Oct 2010 10:51

Re: dotConnect for Oracle. Memory Leak

Post by amirela » Tue 16 Apr 2013 04:17

Or i incorrect use IAsync methods (BeginOpen, BeginExecureReader etc)?
In case of intensive oracle activity it causes more than 4 GB memory leak in 24h

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: dotConnect for Oracle. Memory Leak

Post by Shalex » Tue 16 Apr 2013 15:58

We cannot reproduce the problem in our environment. Please specify the following details:
1) the exact (x.xx.xxx) version of your dotConnect for Oracle
2) describe the memory leaks you are experiencing:
a) is memory usage increasing step-by-step or the program should be running for some time before we can see memory leaks?
b) are you running the code in the debug mode or as a separate *.exe?

amirela
Posts: 15
Joined: Tue 26 Oct 2010 10:51

Re: dotConnect for Oracle. Memory Leak

Post by amirela » Wed 17 Apr 2013 03:42

Sorry, i found that memory leak appears only in multi-threaded environment.
Run compiled "exe" file.

Versions:
Devart.Data : 5.0.401.0
Devart.Data.Oracle : 6.70.302.0
Oracle x64 client: 10.2.0.1

Code: Select all

private void button1_Click(object sender, EventArgs e)
{
	while (true)
	{
		ManualResetEvent evt1 = new ManualResetEvent(false);
		ManualResetEvent evt2 = new ManualResetEvent(false);
		ManualResetEvent evt3 = new ManualResetEvent(false);
		ManualResetEvent evt4 = new ManualResetEvent(false);
		ManualResetEvent evt5 = new ManualResetEvent(false);

		var workedThread = new Thread(DoWork) { IsBackground = true };
		workedThread.Start(evt1);

		workedThread = new Thread(DoWork) { IsBackground = true };
		workedThread.Start(evt2);

		workedThread = new Thread(DoWork) { IsBackground = true };
		workedThread.Start(evt3);

		workedThread = new Thread(DoWork) { IsBackground = true };
		workedThread.Start(evt4);

		workedThread = new Thread(DoWork) { IsBackground = true };
		workedThread.Start(evt5);

		evt1.WaitOne();
		evt2.WaitOne();
		evt3.WaitOne();
		evt4.WaitOne();
		evt5.WaitOne();
	}
}

private void DoWork(object state)
{
	OracleConnection connection = null;
	try
	{
		connection = new OracleConnection("Data Source=invalid_data_source;User ID=test;Password=test;Pooling=true;Validate Connection=True;Max Pool Size=10;Connection Timeout=5;");
		//connection.Open();

		var result = connection.BeginOpen(null, null);
		if (WaitHandle.WaitAny(new[] { result.AsyncWaitHandle },
								connection.ConnectionTimeout > 0 ? connection.ConnectionTimeout * 1000 : -1) ==
			WaitHandle.WaitTimeout)
		{
			connection.Close();
			throw new TimeoutException("Timeout");
		}
		connection.EndOpen(result);
	}
	catch (Exception ex)
	{
		;
	}
	finally
	{
		if (connection != null)
		{
			connection.Close();
			connection.Dispose();
			connection = null;
		}
		((ManualResetEvent)state).Set();
	}
}

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: dotConnect for Oracle. Memory Leak

Post by Pinturiccio » Fri 19 Apr 2013 11:21

We have reproduced the issue. We will investigate it and notify you about the results as soon as possible.

amirela
Posts: 15
Joined: Tue 26 Oct 2010 10:51

Re: dotConnect for Oracle. Memory Leak

Post by amirela » Mon 24 Jun 2013 09:06

any news on this?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: dotConnect for Oracle. Memory Leak

Post by Pinturiccio » Tue 25 Jun 2013 09:44

We are investigating the issue and will notify you about the results as soon as possible.

amirela
Posts: 15
Joined: Tue 26 Oct 2010 10:51

Re: dotConnect for Oracle. Memory Leak

Post by amirela » Sun 01 Sep 2013 02:39

5 months.....

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: dotConnect for Oracle. Memory Leak

Post by Pinturiccio » Mon 02 Sep 2013 14:00

We are investigating the issue but it is a resource-demanding process so we cannot tell any timeframe at the moment. We will post here as soon as we get some results.

Post Reply