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 » WebSphere Message Broker (ACE) Support » WMB anyver \ clearMessage() and garbage collection

Post new topic  Reply to topic
 WMB anyver \ clearMessage() and garbage collection « View previous topic :: View next topic » 
Author Message
hopsala
PostPosted: Mon Oct 06, 2008 8:37 am    Post subject: WMB anyver \ clearMessage() and garbage collection Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

G'day. I'm curious about the clearMessage() method. All the lit has to say about this subject is:

Quote:
Deletes the resources associated with the message. Propagating the message or referencing it after clearMessage has been called will result in indeterminate behavior.

Java is supposed to have garbage collection utilities, no? so why is this necessary? Is it simply that the message/node objects will be scratched immediately rather than after a while?

Three possible theories:
1. clearMessage() clears broker resources which have nothing to do with java.
2. IBM were unable to resolve the java node memory leak problems they had (http://www.mqseries.net/phpBB2/viewtopic.php?t=44898), so wmb object resources are not collected by the GC, unless explicitly specified.
3. The GC collects this objects only after a while, which may result in high memory usage. using clearMessage() reduces the broker's resource footprint.

Maybe all are true, maybe neither. So I guess the main question is - is using this method absolutely necessary for healthy processing (otherwise - memory leak galore) or merely a feature which may be used to improve performance?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Oct 06, 2008 8:47 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

clearMessage() has been a required part of the User Defined Node Java API since version 2.1.

Ergo, it has nothing to do with a specific memory leak in a specific release of 6.0.

The answer is, from what I recall, pretty much your #1 only.

Recall that Broker consists of two separate-but-merged runtimes - a C++ runtime and a Java runtime. All of the logical message tree is instanciated and managed by the C++ runtime, and merely exposed to the Java runtime through JNI or suchlike.
Back to top
View user's profile Send private message
hopsala
PostPosted: Tue Oct 07, 2008 7:47 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Quote:
Ergo, it has nothing to do with a specific memory leak in a specific release of 6.0.

The forum thread I gave indicated that the problem persists in 6.1; I just thought it may hint at the possibility that wmb handles java objects memory release outside of Garbage Collection.

Quote:
The answer is, from what I recall, pretty much your #1 only.

Ok, but is it an absolute necessity or a niceity? If I don't code clearMessage() in all my finally{} clauses, will I get memory leaks?

Quote:
...and merely exposed to the Java runtime through JNI or suchlike.

The great mystery of the 'suchlike'... Do you know the specifics?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Oct 07, 2008 7:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

hopsala wrote:
Quote:
Ergo, it has nothing to do with a specific memory leak in a specific release of 6.0.

The forum thread I gave indicated that the problem persists in 6.1; I just thought it may hint at the possibility that wmb handles java objects memory release outside of Garbage Collection.


To the best of my knowledge, this is not true. I do not have access to source, though.

hopsala wrote:
Quote:
The answer is, from what I recall, pretty much your #1 only.

Ok, but is it an absolute necessity or a niceity? If I don't code clearMessage() in all my finally{} clauses, will I get memory leaks?


Yes, you will absolutely get memory leaks. Because you have created objects in the C++ runtime that you have not decremented the reference counters on, so that when the Input node goes to quiesce the thread, it can not free up those message tree objects. Again, this is true since the initial exposure of a Java API for User Defined Nodes in 2.1(CSD3ish), which is now also the API used by JavaCompute nodes.

hopsala wrote:
Quote:
...and merely exposed to the Java runtime through JNI or suchlike.

The great mystery of the 'suchlike'... Do you know the specifics?

Even if I did, I wouldn't know if I could share them.

Best bet is to review the C User Defined API, and try and assemble a mental picture of how that works, and then assume that the Java API is just a Java wrapper on that.

It's what will get you the closest to the truth for your needs. Any differences below that should be irrelevant to anyone outside product development.
Back to top
View user's profile Send private message
hopsala
PostPosted: Tue Oct 07, 2008 8:05 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

That's good to know. I actually know one site who had decided not to use clearMessage() at all, thinking it was merely a placeholder. I wish this was somehow emphasized in the IBM lit, or at least mentioned (hint hint..)

Much obliged jeff, as usual
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Oct 07, 2008 8:13 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Anyone can file documentation feedback in the InfoCenter.

hint, hint.
Back to top
View user's profile Send private message
hopsala
PostPosted: Tue Oct 07, 2008 9:18 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Point taken.
Back to top
View user's profile Send private message
JLRowe
PostPosted: Thu Oct 09, 2008 5:21 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Back to top
View user's profile Send private message Send e-mail
hopsala
PostPosted: Fri Oct 10, 2008 10:59 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

JLRowe wrote:
I have been using the MB Java API extensively for years, without memory leaks and without explicit calls to clearMessage().

So have I, and indeed I haven't noticed any significant memory leaks. But what jeff says makes sense, so I think I'll stay on the safe side.

As to the finalize() tip - a most excellent idea and I embrace it full-heartedly. I can only hope that the broker releases the references to node objects when the flow finishes (that is, one message goes end-to-end in one flow). I'll debug a bit to see when finalize() is called and post my results here.
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 » WebSphere Message Broker (ACE) Support » WMB anyver \ clearMessage() and garbage collection
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.