You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Arnaud Marchand <a....@progeri.com> on 2013/10/13 13:37:01 UTC

Camel Javascript Leak

Hi,

I am experiencing a memory leak in the following conditions:

1) I Have a small application, built using Maven against the version 2.12.1
of camel. There is no trick to get a particular version of any library in my
pom.xml

2) I only use the spring xml DSL files

3) I use ActiveMQ as Broker

4) I use external javascript scripts in some of my routes

The problem occurs when I load a script via a resource as shown in the next
route:

*<route id="TestLeak">
      <from uri="jms:topic:INMES"/>
      <to
uri="language:javascript:file:/pathtomyscriptlib/javascript.js?contentCache=true"/>
      <to uri="log:RES"/>
      <to uri="jms:topic:OUTMES"/>
</route>
*

The problem occurs when the *contentCache* is set to false. In fact
everything works correctly in both cases (True or False) but if the cache is
not used, a memory leak appears (After a few thousands of messages if the
Java Memory Heap is set to 512MB). 

The problem should be easy to reproduce.

I did not check the code yet, but I suppose that the leak can be in the
resource management of the Rhino library used by Camel.

I agree that instantiating a script engine per message is highly
inefficient, but that is convenient during the test phases.

Thanks for your help,



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Javascript-Leak-tp5741468.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Javascript Leak

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have noticed a problem and logged a ticket
https://issues.apache.org/jira/browse/CAMEL-6870

On Mon, Oct 14, 2013 at 11:01 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Yeah sounds like some resources need to be closed after processing the
> javascript. Feel free to dive into the code to see if you can find a
> solution.
>
> On Sun, Oct 13, 2013 at 1:37 PM, Arnaud Marchand <a....@progeri.com> wrote:
>> Hi,
>>
>> I am experiencing a memory leak in the following conditions:
>>
>> 1) I Have a small application, built using Maven against the version 2.12.1
>> of camel. There is no trick to get a particular version of any library in my
>> pom.xml
>>
>> 2) I only use the spring xml DSL files
>>
>> 3) I use ActiveMQ as Broker
>>
>> 4) I use external javascript scripts in some of my routes
>>
>> The problem occurs when I load a script via a resource as shown in the next
>> route:
>>
>> *<route id="TestLeak">
>>       <from uri="jms:topic:INMES"/>
>>       <to
>> uri="language:javascript:file:/pathtomyscriptlib/javascript.js?contentCache=true"/>
>>       <to uri="log:RES"/>
>>       <to uri="jms:topic:OUTMES"/>
>> </route>
>> *
>>
>> The problem occurs when the *contentCache* is set to false. In fact
>> everything works correctly in both cases (True or False) but if the cache is
>> not used, a memory leak appears (After a few thousands of messages if the
>> Java Memory Heap is set to 512MB).
>>
>> The problem should be easy to reproduce.
>>
>> I did not check the code yet, but I suppose that the leak can be in the
>> resource management of the Rhino library used by Camel.
>>
>> I agree that instantiating a script engine per message is highly
>> inefficient, but that is convenient during the test phases.
>>
>> Thanks for your help,
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Camel-Javascript-Leak-tp5741468.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Javascript Leak

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah sounds like some resources need to be closed after processing the
javascript. Feel free to dive into the code to see if you can find a
solution.

On Sun, Oct 13, 2013 at 1:37 PM, Arnaud Marchand <a....@progeri.com> wrote:
> Hi,
>
> I am experiencing a memory leak in the following conditions:
>
> 1) I Have a small application, built using Maven against the version 2.12.1
> of camel. There is no trick to get a particular version of any library in my
> pom.xml
>
> 2) I only use the spring xml DSL files
>
> 3) I use ActiveMQ as Broker
>
> 4) I use external javascript scripts in some of my routes
>
> The problem occurs when I load a script via a resource as shown in the next
> route:
>
> *<route id="TestLeak">
>       <from uri="jms:topic:INMES"/>
>       <to
> uri="language:javascript:file:/pathtomyscriptlib/javascript.js?contentCache=true"/>
>       <to uri="log:RES"/>
>       <to uri="jms:topic:OUTMES"/>
> </route>
> *
>
> The problem occurs when the *contentCache* is set to false. In fact
> everything works correctly in both cases (True or False) but if the cache is
> not used, a memory leak appears (After a few thousands of messages if the
> Java Memory Heap is set to 512MB).
>
> The problem should be easy to reproduce.
>
> I did not check the code yet, but I suppose that the leak can be in the
> resource management of the Rhino library used by Camel.
>
> I agree that instantiating a script engine per message is highly
> inefficient, but that is convenient during the test phases.
>
> Thanks for your help,
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Javascript-Leak-tp5741468.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen