Message Queueing + Database = Memory Leak??

  • Thread starter Thread starter Marcin Belczewski
  • Start date Start date
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 = @"FormatName:DIRECT="
+ "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);
}
}
}
}
}
}
 
messagequeue is not related to database operations. how much data are you
sending to the queue and why is it taking 100Megs? Sending that much data
over to a network queue after coming from a database is a bad idea.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
 
Alvin said:
messagequeue is not related to database operations. how much data are you
sending to the queue and why is it taking 100Megs? Sending that much data
over to a network queue after coming from a database is a bad idea.
I'm sending just small pieces of data - in the code example i put the
code into the loop to separate the issue - In out live system it
happened that after two weeks of working whole memory was consumed.
This is just the code sample - and can anyone explain the behaviour here?
Why there's no issue when no database connection is being done?
And the issue (somewhat related to Message Queueing) occurs when
database connection is there?

Regards,
Marcin
 
Back
Top