classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] RFC: Use WeakHashMap in java.util.ResourceBundle


From: Robert Schuster
Subject: [cp-patches] RFC: Use WeakHashMap in java.util.ResourceBundle
Date: Mon, 19 Sep 2005 11:26:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.11) Gecko/20050916

Hi,
I changed cacheBundle to be of type WeakHashMap because I think this would fix
the problems mentioned in PR 23952[0].

Apart from that I changed the static type of bundleCache to WeakHashMap to avoid
calling methods via the Map interface because I am under the impression that
most VMs can work more efficiently then.

2005-09-19  Robert Schuster  <address@hidden>

    * java/util/ResourceBundle.java: Changed type of bundleCache
    to WeakHashMap.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23952
Index: java/util/ResourceBundle.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/ResourceBundle.java,v
retrieving revision 1.35
diff -u -r1.35 ResourceBundle.java
--- java/util/ResourceBundle.java       13 Sep 2005 22:19:15 -0000      1.35
+++ java/util/ResourceBundle.java       19 Sep 2005 09:12:56 -0000
@@ -105,8 +105,12 @@
 
   /**
    * The resource bundle cache.
+   *
+   * <p>Chosing a WeakHashMap here is done deliberately because
+   * this prevents unlimited memory consumption when many bundles
+   * are loaded.</p>
    */
-  private static Map bundleCache;
+  private static WeakHashMap bundleCache;
 
   /**
    * The last default Locale we saw. If this ever changes then we have to
@@ -375,7 +379,7 @@
     Locale defaultLocale = Locale.getDefault();
     if (defaultLocale != lastDefaultLocale)
       {
-       bundleCache = new HashMap();
+       bundleCache = new WeakHashMap();
        lastDefaultLocale = defaultLocale;
       }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]