|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQ holding Memory after qmanager disconnection |
« View previous topic :: View next topic » |
Author |
Message
|
balaji sr |
Posted: Thu Apr 02, 2009 11:31 pm Post subject: MQ holding Memory after qmanager disconnection |
|
|
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 |
|
 |
WMBDEV1 |
Posted: Fri Apr 03, 2009 4:36 am Post subject: |
|
|
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 |
|
 |
balaji sr |
Posted: Fri Apr 03, 2009 6:01 am Post subject: |
|
|
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 |
|
 |
WMBDEV1 |
Posted: Fri Apr 03, 2009 6:19 am Post subject: |
|
|
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|