473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

OutOfMemoryException when using MessageQueueTransaction

Ash
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!
Nov 17 '05 #1
2 3466
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

"Ash" <As*@discussions.microsoft.com> wrote in message
news:A0**********************************@microsof t.com...
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!

Nov 17 '05 #2
Ash
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.

"Ollie Riches" wrote:
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

"Ash" <As*@discussions.microsoft.com> wrote in message
news:A0**********************************@microsof t.com...
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!


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ryan Seghers | last post by:
I've got a program that has no user interface (like a service but not actually a Windows Service yet) in which I'd like to handle OutOfMemoryExceptions. I'd at least like to log the failure before...
0
by: Per Bergland | last post by:
After many woes, I finally managed to get a stack dump of my System Service (written in C#) that insists on crashing when launched at system boot time (see below on how to get this dump - I...
2
by: Fernando Casero | last post by:
Hi, I'm programming on Visual C# Express Beta 2 and I have the following code: class MyClass { int a = new int int b = new int public int SomeMethod() }
3
by: Michael | last post by:
I have a problem with catching the OutOfMemoryException in a managed C+ application. When creating small objects on the managed heap neithe the catch handler for OutOfMemoryException nor the...
1
by: SMG - Idealake | last post by:
Hi all, I am getting following error on my error, what could be the reason? Exception of type System.OutOfMemoryException was thrown. Description: An unhandled exception occurred during the...
2
by: Dave | last post by:
We just started getting this error message in our application today (stack trace below). From the OutOfMemoryException, I'm guessing it could be a memory leak. I'm making sure I'm closing all my...
1
by: Ashkan Daie | last post by:
Hi All, When trying to install a performance counter via InstallUtil I get the following exception: Creating performance counter category Enterprise Library Caching. An exception occurred...
13
by: Venkatachalam | last post by:
Hi, In my application I have text(flat) file as input and I have to generate an XML file. The maximum input text file size can be 900MB and gererated xml may result 2+ GB. Based on the first...
8
by: =?Utf-8?B?UGlnZ3k=?= | last post by:
Hi to all, I am getting this System.OutOfMemoryException calling the Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method. The type of <streamis...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.