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 Java / JMS » MQ holding Memory after qmanager disconnection

Post new topic  Reply to topic
 MQ holding Memory after qmanager disconnection « View previous topic :: View next topic » 
Author Message
balaji sr
PostPosted: Thu Apr 02, 2009 11:31 pm    Post subject: MQ holding Memory after qmanager disconnection Reply with quote

Apprentice

Joined: 07 Jan 2003
Posts: 28

Hi,
I am trying put message into MQ after reading contents from file.
I have noticed that mqqueue is holding memory after queue is closed and qmanager is closed and disconnected for a large file (20 MB) .
On running on code jprofiler it shows there is thread "com.ibm.mq.server.MQThread" in blocked state.
Following are the code snippets

Code:

   public void putMessage(MQMessage theMsg) throws Exception {
      System.out.println("Start : Total memory in use = "   + Runtime.getRuntime().totalMemory());
      MQQueueManager queueManager = null;
      MQQueue queue = null;
      try {
         int openOptions = MQC.MQOO_OUTPUT;
         queueManager = new MQQueueManager(qManager, MQC.MQCNO_NONE);
         queue = queueManager.accessQueue(qname, openOptions);
         MQPutMessageOptions pmo = new MQPutMessageOptions();
         pmo.options = MQC.MQPMO_LOGICAL_ORDER | MQC.MQPMO_SYNCPOINT;
         System.out.println("Before put :Total memory in use = " + Runtime.getRuntime().totalMemory());
         queue.put(theMsg, pmo);
         queueManager.commit();
         System.out.println("After put :Total memory in use = " + Runtime.getRuntime().totalMemory());
         theMsg.clearMessage();
         theMsg = null;
         System.out.println("Message written to Queue");
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         queue.close();
         queue = null;
         queueManager.close();
         queueManager.disconnect();
         queueManager = null;
      }
      System.out.println("End : Total memory in use = " + Runtime.getRuntime().totalMemory());
   }


Following are Output:
Start : Total memory in use = 60956672
Before put :Total memory in use = 60956672
After put :Total memory in use = 76427264
Message written to Queue
End : Total memory in use = 76427264


Could anyone anyone explain what is reason for this?
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
WMBDEV1
PostPosted: Fri Apr 03, 2009 4:36 am    Post subject: Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

Looks like the memory used by the JVM has increased to accomodate the large message which is normal behaviour. The JVM will choose when it decides to grow / reduce the memory it has allocated. The memory may not have been garbage collected either, you cannot control this.

I recommend you read about JVMs to understand how they manage memory. Looks like normal behvaiour to me though.
Back to top
View user's profile Send private message
balaji sr
PostPosted: Fri Apr 03, 2009 6:01 am    Post subject: Reply with quote

Apprentice

Joined: 07 Jan 2003
Posts: 28

Thanks for your reply.
I have set maximum memory has 512 MB.
Till i run system.gc() memory is not released .If i comment system.gc() its is holding up memory permanently i have monitored this for 1 hour
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
WMBDEV1
PostPosted: Fri Apr 03, 2009 6:19 am    Post subject: Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

The .gc() only suggests to the JVM to clean up, it does not force it to and so the behaviour you see may not always be replicated.

There are a number of different types of gc, im guessing you're running the default "stop the world" collector. The gc will probably run when there is no more memory available and will at that point free up the objects that are no longer referenced. At this point the JVM may increase the memory it has (up to a max of 512MB in this case), reduce the memory it has, returning it to the OS or keep the allocation the same. If it keeps ot the same, the figure you are seeing will always be the same but the amount of free memory within this chunk will vary.

Again, this still feels normal to me. Have a read of the default GC to see how it works.
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 Java / JMS » MQ holding Memory after qmanager disconnection
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.