[2005-07-17 20:05] Hugh Allen said: | Sorry - I have not followed this thread very closely, but I noticed you wrote: | | "I saw (not surprisingly) that I had 2.6 million Strings in it (a majority of them _very_ small strings" | | When you have lots of strings with the same value it is important to use String.intern(). Strings are handled in a very special way by the JVM, compared to other objects. Interned strings are kept in a pool and there is ONLY ONE INSTANCE FOR EACH VALUE. You can compare interned strings with == instead of .equals(). | | String.intern() can reduce memory consumption dramatically.
I did this for the keys to the Field Map keys and the Field name since there is a limited set of values for them. Doing this gave a modest savings of 27MB. Doing intern() for the Field Map values yields memory savings of 240MB!, making the memory consumption 81M, but causes the program's run time to increase from ~30 sec. to ~4 minutes. Because there are a fair number of small recurring values for the Field Map values, I tried using intern() for Strings shorter than 10 chars and saved a total of 61MB over the non-intern() approach while only incurring a 3 second runtime penalty. Thanks for this tip! b _______________________________________________ Juglist mailing list [email protected] http://trijug.org/mailman/listinfo/juglist_trijug.org
