From 23f363be862f76417d305b3b52dc23f2eab03119 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 7 Jun 2012 13:23:48 +0000 Subject: Allow layouts to be reclaimed. --- .../amazon/carbonado/raw/GenericStorableCodec.java | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/amazon') diff --git a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java index d9fe3e2..681909a 100644 --- a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java +++ b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java @@ -18,6 +18,7 @@ package com.amazon.carbonado.raw; +import java.lang.ref.WeakReference; import java.lang.reflect.Method; import java.lang.reflect.UndeclaredThrowableException; import java.util.Map; @@ -931,15 +932,17 @@ public class GenericStorableCodec implements StorableCodec mLayoutRef; + private final int mHashCode; LayoutKey(Layout layout) { - mLayout = layout; + mLayoutRef = new WeakReference(layout); + mHashCode = layout.getStorableTypeName().hashCode() * 7 + layout.getGeneration(); } @Override public int hashCode() { - return mLayout.getStorableTypeName().hashCode() * 7 + mLayout.getGeneration(); + return mHashCode; } @Override @@ -948,12 +951,20 @@ public class GenericStorableCodec implements StorableCodec