OutOfMemoryException when using MessageQueueTransaction

G

Guest

Hi,
I'm working on an application that takes csv files then converts it to XML.
It then write the XML to a msmq where another service is reading the queue
and sends it to the DB.

My question is:
My application flies (when using the Message object to wrap my data in a
non-transactional Q.
When using MessageQueueTransaction in a transactional Q the memory usage (in
task manager) keeps getting larger (as if GC never cleans up)
until my application throws OutOfMemoryException.

The problem is I HAVE to use transactional Queues since the modules that
writes data to the DB can only read transactional queues.
Even if i didn't have to, I would like to know why do I run out of memory
with Transactional queues.

I run out of memory depending on the size and number of the CSV files.

My code is simple...
I create Talk2Q once and i loop on the Send() method

MessageQueueTransaction m;
MessageQueue msgQ;
public Talk2Q(string QName){
msgQ=new MessageQueue(QName)
}
public void Send(string data){
try{
m=new MessageQueueTransaction();
m.Begin();
msgQ.Formatter=new ActiveXMessageFormatter();
msgQ.Send(msg.ToString(),"RTPROS Message",m);
m.Commit();
m=null; //To make sure GC notices it ;)
}catch(Exception e){
m.Abort();
Console.WriteLine("Msg Aborted\n\n"+e.Message+e.StackTrace)
}

Maybe do i need to create the MessageQueueTransaction ONCE only???
Thanks alot!
 
O

Ollie Riches

There are lots of reported issues about memory leaks when using MSMQ in
..Net. If you google 'MSMQ memory leak C#' you should fine plenty. I know
beause I had similar issues about 2 years ago.

What I did notice is that you are not calling Dispose on any of the message
queue objects at all, better still you should think about using the 'using'
keyword.

What version of MSMQ are you using?

HTH

Ollie Riches
 
G

Guest

This might be an embarrasing question but how do you know what version of
msmq is installed? But I think its 2.0 I'm using whatever came with windowsXP
prof. SP2 unless SP updated it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top