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
This commit is contained in:
Robert Davies 2007-02-20 14:26:27 +00:00
parent b0b602121e
commit c74558bfde
1 changed files with 6 additions and 2 deletions

View File

@ -90,6 +90,9 @@ public class UsageManager {
for( int i=0; percentUsage >= 100 ; i++) { for( int i=0; percentUsage >= 100 ; i++) {
usageMutex.wait(); 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.. // Switching from being full to not being full..
if( oldPercentUsage >= 100 && newPercentUsage < 100 ) { if( oldPercentUsage >= 100 && newPercentUsage < 100 ) {
synchronized (usageMutex) { synchronized (usageMutex) {
System.err.println("Memory usage change. from: "+oldPercentUsage+", to: "+newPercentUsage);
usageMutex.notifyAll(); usageMutex.notifyAll();
} }
} }
// Let the listeners know // Let the listeners know
for (Iterator iter = listeners.iterator(); iter.hasNext();) { for (Iterator iter = listeners.iterator(); iter.hasNext();) {
UsageListener l = (UsageListener) iter.next(); UsageListener l = (UsageListener) iter.next();
l.onMemoryUseChanged(this, oldPercentUsage, newPercentUsage); l.onMemoryUseChanged(this, oldPercentUsage, newPercentUsage);
} }
} }
public String toString() { public String toString() {