I forgot the patch. Here it comes now.

/Roman


Am Montag, den 21.11.2005, 15:02 +0100 schrieb Roman Kennke:
> Am Samstag, den 19.11.2005, 19:09 +0100 schrieb Mark Wielaard:
> > Hi Roman,
> > 
> > On Mon, 2005-11-14 at 12:52 +0000, Roman Kennke wrote:
> > > +  /**
> > > +   * The current repaint managers, indexed by their ThreadGroups.
> > > +   */
> > > +  static HashMap currentRepaintManagers;
> > 
> > Isn't this a potential memory leak? Maybe there are not many
> > ThreadGroups in an application ever. But it might be wise to use a
> > WeakHashMap here so that the entry disappears when the ThreadGroup is
> > garbage collected.
> 
> This is fixed using the attached patch.
> 
> 2005-11-21  Roman Kennke  <[EMAIL PROTECTED]>
> 
>         * javax/swing/RepaintManager.java
>         (currentRepaintManagers): Use a WeakHashMap to avoid potential
>         memory leak.
>         (currentManager): Instantiate WeakHashMap instead of HashMap.
>         (setCurrentManager): Instantiate WeakHashMap instead of HashMap.
> 
> /Roman
> 
> _______________________________________________
> Classpath-patches mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/RepaintManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/RepaintManager.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- javax/swing/RepaintManager.java	14 Nov 2005 12:50:01 -0000	1.18
+++ javax/swing/RepaintManager.java	21 Nov 2005 14:01:43 -0000	1.19
@@ -48,6 +48,7 @@
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.WeakHashMap;
 
 /**
  * <p>The repaint manager holds a set of dirty regions, invalid components,
@@ -68,7 +69,7 @@
   /**
    * The current repaint managers, indexed by their ThreadGroups.
    */
-  static HashMap currentRepaintManagers;
+  static WeakHashMap currentRepaintManagers;
   
   /**
    * <p>A helper class which is placed into the system event queue at
@@ -286,7 +287,7 @@
   public static RepaintManager currentManager(Component component)
   {
     if (currentRepaintManagers == null)
-      currentRepaintManagers = new HashMap();
+      currentRepaintManagers = new WeakHashMap();
     ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
     RepaintManager currentManager =
       (RepaintManager) currentRepaintManagers.get(threadGroup);
@@ -330,7 +331,7 @@
   public static void setCurrentManager(RepaintManager manager)
   {
     if (currentRepaintManagers == null)
-      currentRepaintManagers = new HashMap();
+      currentRepaintManagers = new WeakHashMap();
 
     ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
     currentRepaintManagers.put(threadGroup, manager);

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to