Author: j16sdiz
Date: 2008-05-05 12:12:06 +0000 (Mon, 05 May 2008)
New Revision: 19757

Modified:
   trunk/freenet/src/freenet/client/FECCodec.java
Log:
oomhook: reduce max FECRunner on low memory


Modified: trunk/freenet/src/freenet/client/FECCodec.java
===================================================================
--- trunk/freenet/src/freenet/client/FECCodec.java      2008-05-05 12:11:45 UTC 
(rev 19756)
+++ trunk/freenet/src/freenet/client/FECCodec.java      2008-05-05 12:12:06 UTC 
(rev 19757)
@@ -14,6 +14,7 @@
 import freenet.node.PrioRunnable;
 import freenet.support.Executor;
 import freenet.support.Logger;
+import freenet.support.OOMHook;
 import freenet.support.api.Bucket;
 import freenet.support.api.BucketFactory;
 import freenet.support.io.BucketTools;
@@ -27,7 +28,7 @@
  * @author root
  *
  */
-public abstract class FECCodec {
+public abstract class FECCodec implements OOMHook {

        // REDFLAG: Optimal stripe size? Smaller => less memory usage, but more 
JNI overhead

@@ -451,6 +452,20 @@
                }
        }

+       public void handleLowMemory() throws Exception {
+               synchronized (_awaitingJobs) {
+                       maxRunningFECThreads = Math.min(1, maxRunningFECThreads 
- 1);
+                       _awaitingJobs.notify(); // not notifyAll()
+               }
+       }
+
+       public void handleOutOfMemory() throws Exception {
+               synchronized (_awaitingJobs) {
+                       maxRunningFECThreads = 1;
+                       _awaitingJobs.notifyAll();
+               }
+       }
+
        /**
         * An interface wich has to be implemented by FECJob submitters
         * 


Reply via email to