Author: toad
Date: 2009-01-27 17:09:19 +0000 (Tue, 27 Jan 2009)
New Revision: 25320
Modified:
branches/db4o/freenet/src/freenet/support/io/PersistentBlobTempBucketFactory.java
Log:
Don't let freeSlots get too big as the result of a lot of buckets being freed.
Modified:
branches/db4o/freenet/src/freenet/support/io/PersistentBlobTempBucketFactory.java
===================================================================
---
branches/db4o/freenet/src/freenet/support/io/PersistentBlobTempBucketFactory.java
2009-01-27 17:04:45 UTC (rev 25319)
+++
branches/db4o/freenet/src/freenet/support/io/PersistentBlobTempBucketFactory.java
2009-01-27 17:09:19 UTC (rev 25320)
@@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -462,7 +463,16 @@
}
public synchronized void postCommit() {
- freeSlots.putAll(almostFreeSlots);
+ int sz = freeSlots.size() + almostFreeSlots.size();
+ if(sz > MAX_FREE) {
+ Iterator<Map.Entry<Long,PersistentBlobTempBucketTag>>
it = almostFreeSlots.entrySet().iterator();
+ for(int i=sz;i<MAX_FREE && it.hasNext();i++) {
+ Map.Entry<Long,PersistentBlobTempBucketTag>
entry = it.next();
+ freeSlots.put(entry.getKey(), entry.getValue());
+ }
+ } else {
+ freeSlots.putAll(almostFreeSlots);
+ }
almostFreeSlots.clear();
}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs