M
Marcin Belczewski
Hi
I have the following code that when being executed results in
MemoryStream and XmlTextWriter objects not being Disposed proberly.
When text send to queue is quite long it might take 100MB of memory
within seconds!!!
Looks like memory leak.
It happens only when Message Queueing code is mixed with database access
code. When database code is commented out memory leak doesn't appear
Here ODP.NET provider for Oracle is being used but the same happens for
Microsoft Oracle Data Provider as well as Sql Server Provider for
connection SQL Server 2000.
Anyone has an idea?
Regards
Marcin Belczewski
Here's the code:
using System;
using System.Data.SqlClient;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Messaging;
using System.Configuration;
namespace ODP.NET_MSMQ
{
class Class1
{
private static OracleConnection connect()
{
OracleConnection conn = new
OracleConnection(ConfigurationSettings.AppSettings["DSN"]);
conn.Open();
return conn;
}
[STAThread]
static void Main(string[] args)
{
string path = @"FormatNameIRECT="
+ "OS:" + "gda-mgln-tst-01.globalintech.pl"
+ @"\private$\" + "test_queue";
Class1 cl = new Class1();
for(;
{
string cmdText = "select 9999 from dual";
using(OracleConnection conn = new
OracleConnection(ConfigurationSettings.AppSettings["DSN"]))
using(OracleCommand cmd = new OracleCommand(cmdText, conn))
{
conn.Open();
int result = Convert.ToInt32(cmd.ExecuteScalar());
}
using(MessageQueue outQueue = new MessageQueue(path, false))
{
if (!outQueue.CanWrite)
throw new Exception("Cannot write to output queue: " + outQueue.Path);
using(Message outMessage = new Message())
{
outMessage.Body = "VERY LONG MESSAGE;VERY LONG MESSAGE;VERY LONG
MESSAGE;VERY LONG MESSAGE";
outQueue.Send(outMessage, MessageQueueTransactionType.None);
}
}
}
}
}
}
I have the following code that when being executed results in
MemoryStream and XmlTextWriter objects not being Disposed proberly.
When text send to queue is quite long it might take 100MB of memory
within seconds!!!
Looks like memory leak.
It happens only when Message Queueing code is mixed with database access
code. When database code is commented out memory leak doesn't appear
Here ODP.NET provider for Oracle is being used but the same happens for
Microsoft Oracle Data Provider as well as Sql Server Provider for
connection SQL Server 2000.
Anyone has an idea?
Regards
Marcin Belczewski
Here's the code:
using System;
using System.Data.SqlClient;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Messaging;
using System.Configuration;
namespace ODP.NET_MSMQ
{
class Class1
{
private static OracleConnection connect()
{
OracleConnection conn = new
OracleConnection(ConfigurationSettings.AppSettings["DSN"]);
conn.Open();
return conn;
}
[STAThread]
static void Main(string[] args)
{
string path = @"FormatNameIRECT="
+ "OS:" + "gda-mgln-tst-01.globalintech.pl"
+ @"\private$\" + "test_queue";
Class1 cl = new Class1();
for(;
{
string cmdText = "select 9999 from dual";
using(OracleConnection conn = new
OracleConnection(ConfigurationSettings.AppSettings["DSN"]))
using(OracleCommand cmd = new OracleCommand(cmdText, conn))
{
conn.Open();
int result = Convert.ToInt32(cmd.ExecuteScalar());
}
using(MessageQueue outQueue = new MessageQueue(path, false))
{
if (!outQueue.CanWrite)
throw new Exception("Cannot write to output queue: " + outQueue.Path);
using(Message outMessage = new Message())
{
outMessage.Body = "VERY LONG MESSAGE;VERY LONG MESSAGE;VERY LONG
MESSAGE;VERY LONG MESSAGE";
outQueue.Send(outMessage, MessageQueueTransactionType.None);
}
}
}
}
}
}