diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
index 8268ace7bdefc29f96ea8cee5bd26832a281c0e4..1d108c3f86ab433c1ed8a87bb97e905113091cdf 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
@@ -361,6 +361,20 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
      *  a little higher than 1 or 2. */
     protected final static int MIN_ACTIVE_PEERS = 5;
 
+    /** @since 0.8.7 */
+    private static final int MAX_DB_BEFORE_SKIPPING_SEARCH;
+    static {
+        long maxMemory = Runtime.getRuntime().maxMemory();
+        if (maxMemory == Long.MAX_VALUE)
+            maxMemory = 128*1024*1024l;
+        if (maxMemory < 64*1024*1024)
+            MAX_DB_BEFORE_SKIPPING_SEARCH = 600;
+        else if (maxMemory < 128*1024*1024)
+            MAX_DB_BEFORE_SKIPPING_SEARCH = 900;
+        else
+            MAX_DB_BEFORE_SKIPPING_SEARCH = 1250;
+    }
+
     /** 
       * Search for a newer router info, drop it from the db if the search fails,
       * unless just started up or have bigger problems.
@@ -380,9 +394,14 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
             return;
         }
 
-        if (_context.jobQueue().getMaxLag() > 500) {
+        // should we skip the search?
+        if (_floodfillEnabled ||
+            _context.jobQueue().getMaxLag() > 500 ||
+            getKBucketSetSize() > MAX_DB_BEFORE_SKIPPING_SEARCH) {
             // don't try to overload ourselves (e.g. failing 3000 router refs at
             // once, and then firing off 3000 netDb lookup tasks)
+            // Also don't queue a search if we have plenty of routerinfos
+            // (KBucketSetSize() includes leasesets but avoids locking)
             super.lookupBeforeDropping(peer, info);
             return; 
         }