-
1. Re: How to get memory leak fix into 2.4.x
hchirino Jan 21, 2002 5:53 PM (in response to msquance)Is the jbossmq-client.jar on the client side the one that you built off the HEAD branch??
-
2. Re: How to get memory leak fix into 2.4.x
msquance Jan 23, 2002 12:38 PM (in response to msquance)I can't remember now exactly what I did, but I think I may have been doing something wrong. Regardless, I was able to merge the message cache feature into 2.4.1 and get it working.
However, I found that it didn't solve the problem (except that the messages were written to disk instead of keeping memory).
What I was able to discover is that my problem was related to having a topic subscriber listening for messages that fail to match the message selector. It seems that in this case, references to message are never removed.
I solved it in 2.4.1 (without the message cache merge) by updating BasicQueue.java. Here's the diff (method is internalAddMessage):
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/BasicQueue.java,v
retrieving revision 1.4.2.1
diff -r1.4.2.1 BasicQueue.java
332a333,338
> } else {
> //else add to message list
> synchronized ( messages ) {
> messages.add( message );
> }
334,338d339
< }
<
< //else add to message list
< synchronized ( messages ) {
< messages.add( message );
With the message cache merged, I found that this fix alone did not solve the problem because the reference to the message needed to be removed from the message cache explicitly. I added a hack to BasicQueue that seems to work. Here is the updated code for internalAddMessage:
private void internalAddMessage(MessageReference message) {
//try waiting receivers
synchronized (receivers) {
if (!receivers.isEmpty()) {
for (Iterator it = receivers.iterator(); it.hasNext();) {
Subscription sub = (Subscription) it.next();
try {
if (sub.accepts(message.getHeaders())) {
//queue message for sending to this sub
queueMessageForSending(sub, message);
it.remove();
return;
} else {
// ## added this to remove the message reference - leak otherwise
server.getMessageCache().remove(message);
}
} catch (JMSException ignore) {
cat.debug("Caught unusual exception in internalAddMessage.", ignore);
}
}
} else {
//else add to message list
synchronized (messages) {
messages.add(message);
}
}
}
}
}
Can anyone confirm the bug(s) and/or provide a proper fix?
Thanks,
Mike.