[Mono-bugs] [Bug 77592][Maj] New - Memory leak in OracleParameter when re-using OracleCommand

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Feb 18 11:12:44 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by spatar at mail.nnov.ru.

http://bugzilla.ximian.com/show_bug.cgi?id=77592

--- shadow/77592	2006-02-18 11:12:44.000000000 -0500
+++ shadow/77592.tmp.18661	2006-02-18 11:12:44.000000000 -0500
@@ -0,0 +1,79 @@
+Bug#: 77592
+Product: Mono: Class Libraries
+Version: 1.1
+OS: SUSE 9.2
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 080 Two weeks
+Priority: Major
+Component: Sys.Data
+AssignedTo: tsenganal at novell.com                            
+ReportedBy: spatar at mail.nnov.ru               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Memory leak in OracleParameter when re-using OracleCommand
+
+Description of Problem:
+OracleParameter allocates memory for binding a value but does not free
+previously allocated memory. So, if OracleCommand executes again,
+OracleParameter only allocates new memory again...
+We need badly re-using of the OracleCommand, it would be much better than
+creating always new OracleCommand object for calling the same stored
+procedure or SQL statement.
+
+Steps to reproduce the problem:
+
+using System;
+using System.Data;
+using System.Data.OracleClient;
+
+namespace OracleMemoryLeakTest
+{
+	class OracleMemoryLeakTest
+	{
+		[STAThread]
+		static void Main(string[] args)
+		{
+			string connString = "Data Source=orcl;User ID=scott;Password=tiger";
+			OracleConnection conn = new OracleConnection(connString);
+			conn.Open();
+			OracleCommand comm = conn.CreateCommand();
+			comm.CommandType = CommandType.Text;
+			comm.CommandText = "begin :p_date := sysdate; end;";
+			OracleParameter param;
+			param = comm.Parameters.Add(":p_date", "");
+			param.OracleType = OracleType.VarChar;
+			param.Direction = ParameterDirection.Output;
+			param.Size = 16000; // Why not
+			for (int i=0; i<10000; i++)
+			{
+				comm.ExecuteNonQuery();
+				Console.WriteLine("{0}: {1}", i,
+comm.Parameters[":p_date"].Value.ToString().Trim());
+			}
+			Console.WriteLine("Now see how many memory this process has allocated");
+			Console.ReadLine();
+			comm.Dispose();
+			conn.Close();
+		}
+	}
+}
+
+Actual Results:
+On my machine after executing this application it allocates lot of memory:
+  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
+16422 root      25   0  345m 316m  27m S  0.0 15.6   0:22.34
+OracleMemoryLeakTest
+
+Expected Results:
+Normal memory usaging.
+
+How often does this happen? 
+Always.
+
+Additional Information:
+Oracle 10.2.0.1.0
+Mono 1.1.13.2


More information about the mono-bugs mailing list