You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by litian <li...@hci-tv.com> on 2016/08/30 19:28:12 UTC

Problem with objects not being released from memory.

Hi All,

I have a problem with a program where it appears that objects are never
released from memory. We are using Apache Camel and the HL7 component to
read in HL7 messages. Everything is working, however after a few thousand
messages, the program slows down and eventually stops working. We use
JProfiler to determine where the issue may be coming from. We noticed that
there are Object[], ArrayList, and other HL7 objects that are never cleaned
by the GC and they just kept on growing. When the message gets unmarshaled
it creates all of the objects like arrays, etc.

Currently we are using Camel 2.15.0 with Hapi 2.2.

The code we have for the message processing:

        HL7DataFormat hl7 = new HL7DataFormat();
        
        HapiContext hapiContext = new DefaultHapiContext();
        hapiContext.getParserConfiguration().setValidating(false);
        hl7.setHapiContext(hapiContext);
        
        from("mina2:tcp://" + server + ":" + port +
"?sync=true&codec=#hl7codec")
                .unmarshal(hl7)
                .onException(Exception.class)
                	.handled(true)
                	.transform(ack())
                	.end()
                .validate(messageConforms())
                .choice()
               
.when(header("CamelHL7TriggerEvent").isEqualTo("A01")).to("mock:a01").beanRef("adtMessageHandler",
"handleAdmit").to("mock:a19").transform(ack())
               
.when(header("CamelHL7TriggerEvent").isEqualTo("A02")).to("mock:a02").beanRef("adtMessageHandler",
"handleTransfer").to("mock:a19").transform(ack()) 
               
.when(header("CamelHL7TriggerEvent").isEqualTo("A03")).to("mock:a03").beanRef("adtMessageHandler",
"handleDischarge").to("mock:a19").transform(ack())
                
...

                .end()
                .marshal(hl7);

We tried many things like onCompletion() and process() but the objects
continue to stay in memory. Any suggestions would be greatly appreciated.
Thank you in advance. 



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-objects-not-being-released-from-memory-tp5787010.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with objects not being released from memory.

Posted by litian <li...@hci-tv.com>.
We actually finally figured out yesterday where we went wrong, after a week
of trying different things. It turns out the mock statements hold the
objects in memory forever. It was fine while testing since it does not fill
up the memory for a few thousand messages. After removing the mock from
everything, all the memory for the HAPI messages are cleaned up as expected.
Thank you!



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-objects-not-being-released-from-memory-tp5787010p5787144.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with objects not being released from memory.

Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
I’ve used HAPI quite a bit, and I’ve never noticed a memory leak with it (doesn’t mean it isn’t there though).

Can you tell what object/class is holding the objects?  

When you said “they’re never cleaned up by the GC”, I’m assuming you forced a GC?



> On Aug 30, 2016, at 1:28 PM, litian <li...@hci-tv.com> wrote:
> 
> Hi All,
> 
> I have a problem with a program where it appears that objects are never
> released from memory. We are using Apache Camel and the HL7 component to
> read in HL7 messages. Everything is working, however after a few thousand
> messages, the program slows down and eventually stops working. We use
> JProfiler to determine where the issue may be coming from. We noticed that
> there are Object[], ArrayList, and other HL7 objects that are never cleaned
> by the GC and they just kept on growing. When the message gets unmarshaled
> it creates all of the objects like arrays, etc.
> 
> Currently we are using Camel 2.15.0 with Hapi 2.2.
> 
> The code we have for the message processing:
> 
>        HL7DataFormat hl7 = new HL7DataFormat();
> 
>        HapiContext hapiContext = new DefaultHapiContext();
>        hapiContext.getParserConfiguration().setValidating(false);
>        hl7.setHapiContext(hapiContext);
> 
>        from("mina2:tcp://" + server + ":" + port +
> "?sync=true&codec=#hl7codec")
>                .unmarshal(hl7)
>                .onException(Exception.class)
>                	.handled(true)
>                	.transform(ack())
>                	.end()
>                .validate(messageConforms())
>                .choice()
> 
> .when(header("CamelHL7TriggerEvent").isEqualTo("A01")).to("mock:a01").beanRef("adtMessageHandler",
> "handleAdmit").to("mock:a19").transform(ack())
> 
> .when(header("CamelHL7TriggerEvent").isEqualTo("A02")).to("mock:a02").beanRef("adtMessageHandler",
> "handleTransfer").to("mock:a19").transform(ack()) 
> 
> .when(header("CamelHL7TriggerEvent").isEqualTo("A03")).to("mock:a03").beanRef("adtMessageHandler",
> "handleDischarge").to("mock:a19").transform(ack())
> 
> ...
> 
>                .end()
>                .marshal(hl7);
> 
> We tried many things like onCompletion() and process() but the objects
> continue to stay in memory. Any suggestions would be greatly appreciated.
> Thank you in advance. 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-objects-not-being-released-from-memory-tp5787010.html
> Sent from the Camel - Users mailing list archive at Nabble.com.