[
https://issues.apache.org/jira/browse/CAMEL-14432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Luigi De Masi updated CAMEL-14432:
----------------------------------
Description:
Only Camel 2.X is affected by this issue.
When toD EIP is used and producer cache is disabled, producers' stop method is
not invoked after the exchange is sent. This could lead to a memory leak for
some components.
To reproduce this issue, configure the salesforce credentials in
application.properties and start the camel route of the attached reproducer.
run the following commad:
{{PID=$(ps aux | grep CamelSalesforceExample | grep -v grep | awk '\{print
$2}'); jcmd ${PID} GC.run; jmap -histo ${PID} | grep DefaultRest}}
The route invokes the producer endpoint 5 times, 5 DefaultRestClient objects
are still remained in the heap
The bug is in the implementation of toD (camel-core) and only happens when
producer cache is disabled (cacheSize < 0).
The logic behind "dynamic to EIP" is implemented in SendDynamicProcessor class.
When the producer cache is disabled, SendDynamicProcessor instantiate an
EmptyProducerCache class, a subclass of ProducerCache that mimic the behavior
of his parent creating a new producer in acquireProducer method and stopping
and disposing the producer in releaseProducer method.
After resolving the dynamic uri, SendDynamicProcessor sends the exchange to the
endpoint using ProducerCache.doInAsyncProducer
that in its implementation is not using acquireProducer and releaseProducer
methods to create and dispose the producer. As a consequence of this, a new
producer is created and started but not stopped, producer get unreferenced and
garbage-collected while in started state and so DefaultRestClient is not
removed from SaleforceSession.
A possible workaround is to enable producer cache, setting cacheSize with a
value greater than 0, in this way ProducerCache will use an LRUCache that stops
the producer when an eviction occurs.
was:
Only Camel 2.X is affected by this issue.
When toD EIP is used and producer cache is disabled, producers' stop method is
not invoked after the exchange is sent. This could lead to a memory leak for
some components.
To reproduce this issue, configure the salesforce credentials in
application.properties and start the camel route of the attached reproducer.
run the following commad:
{{PID=$(ps aux | grep CamelSalesforceExample | grep -v grep | awk '\{print
$2}'); jcmd ${PID} GC.run; jmap -histo ${PID} | grep DefaultRest}}
The route invokes the producer endpoint 5 times, 5 DefaultRestClient objects
are still remained in the heap
> camel-salesforce - Memory leak when toD is used with cacheSize < 0 in Camel
> 2.x
> --------------------------------------------------------------------------------
>
> Key: CAMEL-14432
> URL: https://issues.apache.org/jira/browse/CAMEL-14432
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 2.24.3
> Reporter: Luigi De Masi
> Assignee: Luigi De Masi
> Priority: Major
> Fix For: 2.25.1
>
> Attachments: camel-salesforce-upstream.zip
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Only Camel 2.X is affected by this issue.
> When toD EIP is used and producer cache is disabled, producers' stop method
> is not invoked after the exchange is sent. This could lead to a memory leak
> for some components.
> To reproduce this issue, configure the salesforce credentials in
> application.properties and start the camel route of the attached reproducer.
> run the following commad:
> {{PID=$(ps aux | grep CamelSalesforceExample | grep -v grep | awk '\{print
> $2}'); jcmd ${PID} GC.run; jmap -histo ${PID} | grep DefaultRest}}
>
> The route invokes the producer endpoint 5 times, 5 DefaultRestClient objects
> are still remained in the heap
>
> The bug is in the implementation of toD (camel-core) and only happens when
> producer cache is disabled (cacheSize < 0).
> The logic behind "dynamic to EIP" is implemented in SendDynamicProcessor
> class. When the producer cache is disabled, SendDynamicProcessor instantiate
> an EmptyProducerCache class, a subclass of ProducerCache that mimic the
> behavior of his parent creating a new producer in acquireProducer method and
> stopping and disposing the producer in releaseProducer method.
> After resolving the dynamic uri, SendDynamicProcessor sends the exchange to
> the endpoint using ProducerCache.doInAsyncProducer
> that in its implementation is not using acquireProducer and releaseProducer
> methods to create and dispose the producer. As a consequence of this, a new
> producer is created and started but not stopped, producer get unreferenced
> and garbage-collected while in started state and so DefaultRestClient is not
> removed from SaleforceSession.
> A possible workaround is to enable producer cache, setting cacheSize with a
> value greater than 0, in this way ProducerCache will use an LRUCache that
> stops the producer when an eviction occurs.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)