ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » System.OutOfMemoryException on IBM.WMQ.MQQueue.Get

Post new topic  Reply to topic
 System.OutOfMemoryException on IBM.WMQ.MQQueue.Get « View previous topic :: View next topic » 
Author Message
RobP
PostPosted: Wed Jan 19, 2011 12:09 pm    Post subject: System.OutOfMemoryException on IBM.WMQ.MQQueue.Get Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Wed Jan 19, 2011 9:03 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
shashikanth_in
PostPosted: Wed Jan 19, 2011 9:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
RobP
PostPosted: Fri Jan 21, 2011 10:20 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Fri Jan 21, 2011 10:22 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Jan 21, 2011 11:49 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
shashikanth_in
PostPosted: Sat Apr 09, 2011 6:13 am    Post subject: Reply with quote

Centurion

Joined: 26 Feb 2009
Posts: 123

You can download the latest XMS .NET from here:
http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg24011756&loc=en_US&cs=utf-8&lang=en

XMS .NET is very similar to MQ JMS, programming language is different.

MQ v7.0.1.x client is a pre-req.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » System.OutOfMemoryException on IBM.WMQ.MQQueue.Get
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.