Author |
Message
|
RobP |
Posted: Wed Jan 19, 2011 12:09 pm Post subject: System.OutOfMemoryException on IBM.WMQ.MQQueue.Get |
|
|
Newbie
Joined: 08 Nov 2007 Posts: 6
|
Hi,
I have an VB.NET application running on the following setup:
Windows Server 2003 (32 bit)
Websphere MQ 6.0.2.1
4Gb of RAM
It references the amqmdnet.dll in order to access the WMQ API.
The application will occasionally throw a System.OutOfMemoryException when attempting to read a message from a queue. The application stops attempting to read messages by design at this point. There is plenty of free system memory (~1.7GB available). If the application is restarted, the message will be read successfully.
This error comes up occasionally, in the region of a week to a month apart. It does not always originate from the same queue. Other queues being read from, on seperate threads are unaffected when the failure occurs on one thread. I have been unable to reproduce it on a test server with similar setup.
The error stack trace is:
Code: |
Exception of type 'System.OutOfMemoryException' was thrown.
at IBM.WMQ.MQQueue.Get(MQMessage message, MQGetMessageOptions gmo, Int32 maxMsgSize, Int32 spiOptions, Boolean useSPI)
at IBM.WMQ.MQQueue.Get(MQMessage message, MQGetMessageOptions gmo)
at "USER CODE" in GetMessage()
|
For reference details of the function which obtains the message:
Code: |
Public Function GetMessage() As MQMessage
'Setup Message Object
Dim msg = New MQMessage()
If Config.MQPlatformConversion Then
msg.Format = MQFMT_STRING
Else
msg.Format = MQFMT_NONE
End If
msg.Version = 2
'Setup Get Message Options
Dim mqGetMsgOpts As New MQGetMessageOptions
If Config.MQPlatformConversion Then
mqGetMsgOpts.Options = MQBase.MessageGetOptionFlags.BrowseConvert
Else
mqGetMsgOpts.Options = MQBase.MessageGetOptionFlags.Browse
End If
mqGetMsgOpts.WaitInterval = Me.TimeToWaitInMilliseconds
'Read message on Queue (error thrown from HERE)
Receipt_Queue.Get(msg, mqGetMsgOpts)
Return msg
End Function
|
I have had a look around the forums and seen a few other posts related to OutOfMemoryException but they did not seem to relate to .NET or were systematic rather than intermittent errors.
Is this error being thrown by MQ or the .NET framework? I presume the latter as MQ typically throws MqException.
Is this likely due to being unable to allocate enough contiguous space due to fragmentation over time?
Is there anything unconventional about the way I am interacting with MQ that could cause this? Some of the messages can run into the size of 10Mb, could msg.Format = MQFMT_STRING be a contributing factor, I have seen platform conversion mentioned in the other forum posts on this topic.
Any help with the cause of the OutOfMemoryException would be greatly appreciated.
Thanks,
Rob |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jan 19, 2011 9:03 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
It looks to me that you are using a browse cursor and not just trying to do a destructive get.
Are you sure you are clearing / releasing correctly the memory before going on to the next message?
Would you consider using XMS (I believe it will handle all the memory management and cleanup for you in this case)
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
shashikanth_in |
Posted: Wed Jan 19, 2011 9:49 pm Post subject: |
|
|
Centurion
Joined: 26 Feb 2009 Posts: 123
|
Quote: |
Is this likely due to being unable to allocate enough contiguous space due to fragmentation over time? |
The exception is from .NET Framework. MQ .NET exceptions will be of type 'MQException'.
Quote: |
Is there anything unconventional about the way I am interacting with MQ that could cause this? Some of the messages can run into the size of 10Mb, could msg.Format = MQFMT_STRING be a contributing factor, I have seen platform conversion mentioned in the other forum posts on this topic.
|
It may be that MQMessage object returned by your GetMessage method is not getting garbage collected. So over period of time you get out of memory exception. |
|
Back to top |
|
 |
RobP |
Posted: Fri Jan 21, 2011 10:20 am Post subject: |
|
|
Newbie
Joined: 08 Nov 2007 Posts: 6
|
Thank you for your replies.
fjb_saper, we use the browse cursor at this point but do the destructive get at a later point.
I was under the impression memory was getting cleared up given that the memory footprint of the app does not grow.
I am not familiar with XMS, maybe that's something i can look into a little more.
shashikanth_in, thank you for the confirmation on the error source. Guess I shall try cracking open the .NET memory profiler and see what we get.
Rob |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 21, 2011 10:22 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
RobP wrote: |
fjb_saper, we use the browse cursor at this point but do the destructive get at a later point. |
Off topic to your problem possibly, but that's seldom the best design idea. Better (more efficient) to do a destructive get inside a unit of work & roll it back if you have to. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jan 21, 2011 11:49 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Vitor wrote: |
RobP wrote: |
fjb_saper, we use the browse cursor at this point but do the destructive get at a later point. |
Off topic to your problem possibly, but that's seldom the best design idea. Better (more efficient) to do a destructive get inside a unit of work & roll it back if you have to. |
! _________________ MQ & Broker admin |
|
Back to top |
|
 |
shashikanth_in |
Posted: Sat Apr 09, 2011 6:13 am Post subject: |
|
|
Centurion
Joined: 26 Feb 2009 Posts: 123
|
|
Back to top |
|
 |
|