-
1. Re: HornetQ 2.2.5 Final + Jboss 6.0.0 Final memory leak?
ataylor Oct 14, 2012 8:31 AM (in response to bjornko)its hard to say with out seeing how you are caching your JMS resources, however i must ask why you arent using the JCA managed connection factory, its what you should be using.
-
2. Re: HornetQ 2.2.5 Final + Jboss 6.0.0 Final memory leak?
bjornko Oct 14, 2012 9:32 AM (in response to ataylor)All my JMS resources are held in Threadlocals. I dispose of them if they start misbehaving and create new ones as needed. According to jvisualvm the retained size of my QueueManager is low.
I'll try to reconfigure things to use JCA. I didn't set up HornetQ so I don't know why things are the way they are.
-
3. Re: HornetQ 2.2.5 Final + Jboss 6.0.0 Final memory leak?
ataylor Oct 14, 2012 9:43 AM (in response to bjornko)All my JMS resources are held in Threadlocals. I dispose of them if they start misbehaving and create new ones as needed. According to jvisualvm the retained size of my QueueManager is low.
That seems wrong to me, Typically app servers use thread pools so to avoid resources bleeding from on operation/invocation to another you should always clean them up at the end of the thread invocation, if you are cleaning them up then theres no caching. You should use the JCA, thats what its there for, to give you caching amongst other things
-
4. Re: HornetQ 2.2.5 Final + Jboss 6.0.0 Final memory leak?
bjornko Oct 14, 2012 1:34 PM (in response to ataylor)Maybe I was mistaken.
Our configuration mirrors the example in hornetq-2.2.5.Final/examples/jca-config/server
It sets up a connection factory like this:
<connection-factory name="ConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="ConnectionFactory"/>
<entry name="XAConnectionFactory"/>
</entries>
</connection-factory>
Which i specifiy as resource in my QueueManager. Does that mean I am using JCA, and if so, why is it leaking? I leak wether I cache my JMS resources or not, but significantly more if I don't.
I tried specifying java:/JmsXA as connection manager, but that resulted in this, when trying to send a message. cause=InvalidDestinationException(Not a HornetQ Destination:HornetQQueue[ImportQueue-10])
-
5. Re: HornetQ 2.2.5 Final + Jboss 6.0.0 Final memory leak?
bjornko Oct 15, 2012 6:49 AM (in response to ataylor)So I'm using JCA. I get hold of the ConnectionFactory like this:
@Resource(mappedName = "/ConnectionFactory") ConnectionFactory connectionFactory;
And I send the message like this:
try {
connection = connectionFactory.createConnection();
session = connection.createSession( false, Session.AUTO_ACKNOWLEDGE );
producer = session.createProducer( HornetQJMSClient.createQueue( name ) );
Message message = session.createObjectMessage( holder );
producer.send( message );
} finally {
producer.close();
session.close();
connection.close();
}I'm leaving out some exception handling but you get the idea.
By not caching anything and closing everything, I'm finding that I'm leaking a lot less, and a lot fewer object types. Sessions time out properly. However, I'm still leaking
org.hornetq.utils.ClientSessionFactoryImpl. (Also NettyConnectionFactory, and OrderedExecutorFactory).
Looking at heap dumps I see that a lot of ClientSessionFactoryImpls have closed=true, but they are not getting GCed.
-
6. Re: HornetQ 2.2.5 Final + Jboss 6.0.0 Final memory leak?
ataylor Oct 15, 2012 9:11 AM (in response to bjornko)no you arent using the JCA, you need to use the java:/JmsXA connection factory, fyi this is configured in jms-ds.xml file.
If its not working then your code/config is wrong, take a look at one of the javaee examples shipped with HornetQ
-
7. Re: HornetQ 2.2.5 Final + Jboss 6.0.0 Final memory leak?
bjornko Oct 16, 2012 6:07 AM (in response to ataylor)Thanks for your help, Andy. I was able to figure it out eventually. The InvalidDestinationException when using JmsXA should've been a hint to google.
One of my hornetq maven dependencies (hornetq-jms) was not scoped as provided, so instead of using the bundled hornetq libs that come with jboss, I got a mix, with predictably unpredictable results.
After specifiying JmsXA as the ConnectionFactory and fixing the dependency there are no leaks.