You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/06 09:25:49 UTC

[camel] branch ftp-leak created (now e220e494eb2)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch ftp-leak
in repository https://gitbox.apache.org/repos/asf/camel.git


      at e220e494eb2 CAMEL-19498: camel-core - Pool for non-singleton polling consumer should be limite to capacity size, to avoid growing unlimited and leak memory.

This branch includes the following new commits:

     new e220e494eb2 CAMEL-19498: camel-core - Pool for non-singleton polling consumer should be limite to capacity size, to avoid growing unlimited and leak memory.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 01/01: CAMEL-19498: camel-core - Pool for non-singleton polling consumer should be limite to capacity size, to avoid growing unlimited and leak memory.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch ftp-leak
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e220e494eb29ff80fad2ba84870d8f0ec31b1ec1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Aug 6 11:14:07 2023 +0200

    CAMEL-19498: camel-core - Pool for non-singleton polling consumer should be limite to capacity size, to avoid growing unlimited and leak memory.
---
 .../java/org/apache/camel/support/cache/ServicePool.java  | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java b/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java
index 7164a021bcb..cc4afecca11 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java
@@ -85,7 +85,7 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements
     /**
      * This callback is invoked by LRUCache from a separate background cleanup thread. Therefore we mark the entries to
      * be evicted from this thread only, and then let SinglePool and MultiPool handle the evictions (stop the
-     * producer/consumer safely) when they are acquiring/releases producers/consumers. If we sop the producer/consumer
+     * producer/consumer safely) when they are acquiring/releases producers/consumers. If we stop the producer/consumer
      * from the LRUCache background thread we can have a race condition with a pooled producer may have been acquired at
      * the same time its being evicted.
      */
@@ -94,6 +94,10 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements
         Pool<S> p = pool.get(e);
         if (p != null) {
             p.evict(s);
+            if (capacity > 0 && pool.size() > capacity) {
+                // the pool is growing too large, so we need to stop (stop will remove itself from pool)
+                p.stop();
+            }
         } else {
             // service no longer in a pool (such as being released twice, or can happen during shutdown of Camel etc)
             ServicePool.stop(s);
@@ -192,15 +196,6 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements
         pool.values().forEach(Pool::cleanUp);
     }
 
-    @Override
-    protected void doBuild() throws Exception {
-        // eager load classes
-        SinglePool dummy = new SinglePool();
-        LOG.trace("Loaded {}", dummy.getClass().getName());
-        MultiplePool dummy2 = new MultiplePool();
-        LOG.trace("Loaded {}", dummy2.getClass().getName());
-    }
-
     @Override
     protected void doStart() throws Exception {
         // noop