Index: MRUMemoryStore.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/store/MRUMemoryStore.java,v
retrieving revision 1.16
diff -u -r1.16 MRUMemoryStore.java
--- MRUMemoryStore.java	2001/08/25 03:37:27	1.16
+++ MRUMemoryStore.java	2001/08/26 23:09:58
@@ -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,7 +218,7 @@
               + 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();
             }
           }
@@ -251,6 +251,13 @@
       }
     }
   }
+  
+  /**
+   * Method to check if memory is running low in the jvm.
+   */
+  private boolean memoryLow() {
+    return jvm.totalMemory() > heapsize && jvm.freeMemory() < freememory;
+  }
 
   /**
    * Store the given object in a persistent state. It is up to the
@@ -371,6 +378,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);
     }
