From c74558bfde36fb4c40139d00fb98db0f20c58162 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Tue, 20 Feb 2007 14:26:27 +0000 Subject: [PATCH] Add some additional crude throttling. With cursors being limited by how much they can can page into memory as well as the producer, you can get live locks around space usage - if the allocation reaches 100% git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@509575 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/memory/UsageManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/memory/UsageManager.java b/activemq-core/src/main/java/org/apache/activemq/memory/UsageManager.java index acfd9fa419..61f774dbaa 100755 --- a/activemq-core/src/main/java/org/apache/activemq/memory/UsageManager.java +++ b/activemq-core/src/main/java/org/apache/activemq/memory/UsageManager.java @@ -90,6 +90,9 @@ public class UsageManager { for( int i=0; percentUsage >= 100 ; i++) { usageMutex.wait(); } + for( int i=0; percentUsage > 90 ; i++) { + usageMutex.wait(100); + } } } @@ -246,15 +249,16 @@ public class UsageManager { // Switching from being full to not being full.. if( oldPercentUsage >= 100 && newPercentUsage < 100 ) { synchronized (usageMutex) { + System.err.println("Memory usage change. from: "+oldPercentUsage+", to: "+newPercentUsage); usageMutex.notifyAll(); } } - - // Let the listeners know +// Let the listeners know for (Iterator iter = listeners.iterator(); iter.hasNext();) { UsageListener l = (UsageListener) iter.next(); l.onMemoryUseChanged(this, oldPercentUsage, newPercentUsage); } + } public String toString() {