1 Reply Latest reply on May 22, 2015 2:02 AM by Tomas Remes

    @Inject JMSContext memory leak?

    Craig Jones Newbie

      Hi,

       

      We have an app that updates other components with some rates every second by publishing them on to a topic for the components to listen to and consume the messages.

       

      We have a class called JMSBroadcaster that runs a @Schedule method every second which takes the latest rates and uses our publisher class to send them to the topic.

       

      It seems that after a few days deployed to dev and test environments our application hits out of memory issues (and if i amend the scheduler to publish the rates 100 times a second i can bring my local server down within the hour with memory issues too).

       

      After taking dumps when the box hits the out of memory issues it seems it may be linked to the Injection of JMSContext. Our publisher class is pretty simple and a stripped back version of the publishers send message looks like;

       

      @Inject

      private Instance<JMSContext> context;

       

      public void send(String msg) {

          Message message = context.get().createTextMessage(msg);

          context.get().createProducer().send(destination, message);

      }

       

      I have attached the stack trace from the Leak Suspects report from the hprof file i loaded into Eclipse Memory Analyzer and it points to org.jboss.weld.context.CreationalContextImpl having a large retained heap size.

       

      Are we using the Instance JMSContext properly? Initially we were just injecting a JMSContext directly, but we saw warning messages about concurrent sessions, etc. and from some research, this seemed to be the solution to use, out there on the web.

       

      Any help would appreciated.

       

       

      ... I should also add that the JMSBroadcaster class is a @Singleton and it @Injects the publisher. The publisher is annotated with @Dependent... i have been wondering about this and whether it is the right annotation... will do some more reading up on it.

       

      thanks