diff options
author | Kevin Rushforth <[email protected]> | 2007-04-17 22:13:24 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2007-04-17 22:13:24 +0000 |
commit | 6e794f18042c13a0e7755477dd6ed17eb02d6c75 (patch) | |
tree | 681e6c7b04615b57ff8804b7acaa6cc7be2db075 /src/classes | |
parent | e588f6254c002730b1849e1571d13850efc6511c (diff) |
Fixed issue 478: Memory leak in TransparencySortController
git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@161 9497e636-51bd-65ba-982d-a4982e1767a5
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java index 5acfbd5..7b62b77 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortController.java @@ -45,7 +45,7 @@ package com.sun.j3d.utils.scenegraph.transparency; import java.util.Comparator; -import java.util.HashMap; +import java.util.WeakHashMap; import javax.media.j3d.View; /** @@ -61,9 +61,10 @@ import javax.media.j3d.View; * @since Java 3D 1.4 */ public class TransparencySortController { - - private static HashMap comparators = new HashMap(); - + + // Issue 478 - use a WeakHashMap to avoid holding a reference to a View unnecessarily. + private static WeakHashMap<View,Comparator> comparators = new WeakHashMap<View,Comparator>(); + /** * Set the comparator for the specified view. * @@ -76,7 +77,7 @@ public class TransparencySortController { * @param comparator the comparator to call */ public static void setComparator(View view, Comparator comparator) { - comparators.put(view, comparator); + comparators.put(view, comparator); } /** @@ -86,13 +87,6 @@ public class TransparencySortController { * is no comparator for the view or the view is unknown. */ public static Comparator getComparator(View view) { - Object ret = null; - - ret = comparators.get(view); - - if (ret!=null) - return (Comparator)ret; - - return null; + return comparators.get(view); } } |