aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Bowditch <cbowditch@apache.org>2007-11-20 16:49:13 +0000
committerChris Bowditch <cbowditch@apache.org>2007-11-20 16:49:13 +0000
commita40082ca8dd2cc25281ecad06b233ed400c3996f (patch)
tree3740cc2e82ca872eb85d0fcc5bb980d3145ccdab
parent22cdf131f207ff063f84622d9f8054b68b9c5f6b (diff)
downloadxmlgraphics-fop-a40082ca8dd2cc25281ecad06b233ed400c3996f.tar.gz
xmlgraphics-fop-a40082ca8dd2cc25281ecad06b233ed400c3996f.zip
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
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@596739 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/fo/properties/PropertyCache.java14
-rw-r--r--status.xml4
2 files changed, 13 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/fo/properties/PropertyCache.java b/src/java/org/apache/fop/fo/properties/PropertyCache.java
index c1f9a985c..6d9adb998 100644
--- a/src/java/org/apache/fop/fo/properties/PropertyCache.java
+++ b/src/java/org/apache/fop/fo/properties/PropertyCache.java
@@ -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();
}
}
diff --git a/status.xml b/status.xml
index 907487123..55e3f52fa 100644
--- a/status.xml
+++ b/status.xml
@@ -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