Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-04-17 03:42:05 -0400
committerEike Stepper2013-04-17 03:42:05 -0400
commit07543e3353f867e30cb3855549c386c32beec1e5 (patch)
tree04e21d03e6fc124860e370a6cd1c7298dc7220d1
parentf9cd044fd749901b8d5a6a72be95cf341ccbb41e (diff)
downloadcdo-07543e3353f867e30cb3855549c386c32beec1e5.tar.gz
cdo-07543e3353f867e30cb3855549c386c32beec1e5.tar.xz
cdo-07543e3353f867e30cb3855549c386c32beec1e5.zip
[405852] Memory leak in CDOCommitInfoManagerImpl.cache
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405852
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java
index 195e7a811b..d8d039c707 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -34,7 +35,7 @@ import java.util.WeakHashMap;
public class CDOCommitInfoManagerImpl extends CDOCommitHistoryProviderImpl<CDOBranch, CDOCommitHistory> implements
InternalCDOCommitInfoManager
{
- private final Map<CDOCommitInfo, CDOCommitInfo> cache;
+ private final Map<CDOCommitInfo, WeakReference<CDOCommitInfo>> cache;
private final Object cacheLock = new Object();
@@ -50,7 +51,7 @@ public class CDOCommitInfoManagerImpl extends CDOCommitHistoryProviderImpl<CDOBr
{
if (caching)
{
- cache = new WeakHashMap<CDOCommitInfo, CDOCommitInfo>();
+ cache = new WeakHashMap<CDOCommitInfo, WeakReference<CDOCommitInfo>>();
}
else
{
@@ -294,13 +295,14 @@ public class CDOCommitInfoManagerImpl extends CDOCommitHistoryProviderImpl<CDOBr
{
synchronized (cacheLock)
{
- CDOCommitInfo cachedCommitInfo = cache.get(commitInfo);
+ WeakReference<CDOCommitInfo> ref = cache.get(commitInfo);
+ CDOCommitInfo cachedCommitInfo = ref != null ? ref.get() : null;
if (cachedCommitInfo != null)
{
return cachedCommitInfo;
}
- cache.put(commitInfo, commitInfo);
+ cache.put(commitInfo, new WeakReference<CDOCommitInfo>(commitInfo));
}
}

Back to the top