Index: MRUMemoryStore.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/store/MRUMemoryStore.java,v
retrieving revision 1.15
diff -u -r1.15 MRUMemoryStore.java
--- MRUMemoryStore.java	2001/08/24 00:33:10	1.15
+++ MRUMemoryStore.java	2001/08/24 23:31:18
@@ -207,7 +207,7 @@
     if(Thread.currentThread().getName().equals("checker")) {
       while (true) {
         // amount of memory used is greater then heapsize
-        if (this.jvm.totalMemory() - this.jvm.freeMemory() > this.heapsize) {
+        if (memoryLow()) {
           getLogger().debug(
 	    "Invoking garbage collection, total memory = " +
 	    this.jvm.totalMemory() + ", free memory = " + this.jvm.freeMemory()
@@ -218,12 +218,21 @@
 	    "Garbage collection complete, total memory = " +
 	    this.jvm.totalMemory() + ", free memory = " + this.jvm.freeMemory()
 	  );
+           getLogger().debug(
+      "Store size BEFORE cleanup=" + 
+      this.cache.size()
+    );
           synchronized (this) {
-            while ((this.cache.size() > 0) && (this.jvm.freeMemory() < this.freememory)) {
+            while ((this.cache.size() > 0) && memoryLow()) {
               this.free();
             }
+            getLogger().debug(
+      "Store size AFTER cleanup=" + 
+      this.cache.size()
+    );
           }
         }
+        
         try {
           Thread.currentThread().sleep(this.cleanupthreadinterval * 1000);
         } catch (InterruptedException ignore) {}
@@ -250,6 +259,11 @@
     }
   }
 
+  private boolean memoryLow() {
+    return jvm.totalMemory() > heapsize && jvm.freeMemory () < freememory;
+  }
+
+
   /**
    * Store the given object in a persistent state. It is up to the
    * caller to ensure that the key has a persistent state across
@@ -289,6 +303,7 @@
     this.cache.put(key, value);
     this.mrulist.remove(key);
     this.mrulist.addFirst(key);
+    getLogger().debug("Size of store=" + this.cache.size());
   }
 
   /**
@@ -339,7 +354,9 @@
     getLogger().debug("Removing object from store");
     this.cache.remove(key);
     this.mrulist.remove(key);
-    this.fsstore.remove(getFileName(key.toString()));
+    if (this.filesystem) {
+      this.fsstore.remove(getFileName(key.toString()));
+    }
   }
 
   /**
@@ -367,6 +384,8 @@
     try {
       this.cache.remove(this.mrulist.getLast());
       this.mrulist.removeLast();
+      this.jvm.runFinalization();
+      this.jvm.gc();
     } catch (Exception e) {
       getLogger().error("Error in free()", e);
     }
