You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by cb...@apache.org on 2007/11/20 17:49:13 UTC

svn commit: r596739 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/properties/PropertyCache.java status.xml

Author: cbowditch
Date: Tue Nov 20 08:49:13 2007
New Revision: 596739

URL: http://svn.apache.org/viewvc?rev=596739&view=rev
Log:
bug fix: memory leak in PropertyCache. Fix provided by Jeremias. There are still some thread synchronization issues to be addressed in the PropertyCache. See the following thread for details: http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-dev/200711.mbox/%3cBAY117-DAV109E36CC066889386AB917FB870@phx.gbl%3e

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyCache.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyCache.java?rev=596739&r1=596738&r2=596739&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyCache.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyCache.java Tue Nov 20 08:49:13 2007
@@ -76,6 +76,10 @@
             this.ref = old.ref;
             this.hash = old.hash;
         }
+
+        public boolean isCleared() {
+            return (ref == null || ref.get() == null);
+        }
         
     }
     
@@ -116,10 +120,8 @@
                 
                 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 @@
                         /* 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 @@
                 /* 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();
             }
         }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=596739&r1=596738&r2=596739&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Nov 20 08:49:13 2007
@@ -28,6 +28,10 @@
 
   <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



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org