]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
bug fix: memory leak in PropertyCache. Fix provided by Jeremias. There are still...
authorChris Bowditch <cbowditch@apache.org>
Tue, 20 Nov 2007 16:49:13 +0000 (16:49 +0000)
committerChris Bowditch <cbowditch@apache.org>
Tue, 20 Nov 2007 16:49:13 +0000 (16:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@596739 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/properties/PropertyCache.java
status.xml

index c1f9a985c6dd41f6f0eca92ff92f465e37bb79d4..6d9adb998341c8e77950ea019797199650e0d55b 100644 (file)
@@ -76,6 +76,10 @@ public final class PropertyCache {
             this.ref = old.ref;
             this.hash = old.hash;
         }
+
+        public boolean isCleared() {
+            return (ref == null || ref.get() == null);
+        }
         
     }
     
@@ -116,10 +120,8 @@ public final class PropertyCache {
                 
                 int index = this.hash & (table.length - 1);
                 CacheEntry first = table[index];
-                WeakReference ref;
                 for (CacheEntry e = first; e != null; e = e.next) {
-                    ref = e.ref;
-                    if (ref != null && ref.get() == null) {
+                    if (e.isCleared()) {
                         /* remove obsolete entry
                         /* 1. clear value, cause interference for non-blocking get() */
                         e.ref = null;
@@ -127,7 +129,9 @@ public final class PropertyCache {
                         /* 2. clone the segment, without the obsolete entry */
                         CacheEntry head = e.next;
                         for (CacheEntry c = first; c != e; c = c.next) {
-                            head = new CacheEntry(c, head);
+                            if (!c.isCleared()) {
+                                head = new CacheEntry(c, head);
+                            }
                         }
                         table[index] = head;
                         segment.count--;
@@ -177,7 +181,7 @@ public final class PropertyCache {
                 /* launch cleanup in a separate thread, 
                  * so it acquires its own lock, and put()
                  * can return immediately */
-                Thread cleaner = new Thread(new CacheCleaner(hash));
+                Thread cleaner = new Thread(new CacheCleaner(hash), "FOP PropertyCache Cleaner");
                 cleaner.start();
             }
         }
index 9074871234fa46be50938342fbdd802900f8a21c..55e3f52fa2e6ffd3e9ff48a5c60256186f5da9dd 100644 (file)
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="fix">
+        Memory Leak fixed in the Property Cache. Fixed by Jeremias Maerki. Reported and Tested By
+        Chris Bowditch.
+      </action>
       <action context="Code" dev="VH" type="fix">
         Bugfix in tables: wrong element generation by the merging algorithm when glues must be
         produced to cope with conditional spaces. The corresponding length was added twice: one in