dims        01/08/28 06:31:46

  Modified:    src/org/apache/cocoon/components/store MRUMemoryStore.java
  Log:
  Patch from "Gerhard Froehlich" <[EMAIL PROTECTED]>
  for "patch mrumemorystore - some changes in the cleanup thread"
  
  Revision  Changes    Path
  1.17      +11 -2     
xml-cocoon2/src/org/apache/cocoon/components/store/MRUMemoryStore.java
  
  Index: MRUMemoryStore.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/store/MRUMemoryStore.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- MRUMemoryStore.java       2001/08/25 03:37:27     1.16
  +++ MRUMemoryStore.java       2001/08/28 13:31:46     1.17
  @@ -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);
       }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to