| Qiaosheng's profile没有的空间PhotosBlogLists | Help |
|
September 25 GC of "new String()"Quited different between " " and new String(" "), if String contents are equal.
Test1: Set<String> collection = new
HashSet<String>();
String
sql = null;
for ( int i=0; i<100000; i ++ ){
sql =
"xyz";
collection .add(sql);
}
System.out.print("done. You can check the
jvm");
Thread.sleep(10000);
num #instances #bytes class
name
-------------------------------------- 1: 523 87208 [C 2: 135 47920 [B 3: 12 31096 [I 4: 323 13824 [Ljava.lang.Object; 5: 32 10240 <objArrayKlassKlass> 6: 385 9240 java.lang.String 7: 92 4416 java.nio.HeapCharBuffer 8: 91 4368 java.nio.HeapByteBuffer 9: 42 4032 java.lang.Class 10: 55 3960 java.lang.reflect.Field 11: 56 1888 [Ljava.lang.String; 12: 11 1720 <constMethodKlass> 13: 45 1472 <symbolKlass> 14: 18 1440 [Ljava.util.HashMap$Entry; 15: 58 1392 java.util.Hashtable$Entry 16: 10 1040 [Ljava.util.Hashtable$Entry; 17: 61 976 java.lang.StringBuilder Test 2:
Set<String> collection = new
HashSet<String>();
String
sql = null;
for ( int i=0; i<100000; i ++ ){
sql = new String(
"xyz");
collection .add(sql);
}
System.out.print("done. You can check the
jvm");
Thread.sleep(10000);
num
#instances #bytes class
name -------------------------------------- 1: 31782 762768 java.lang.String 2: 212 45528 [C 3: 17 25520 [B 4: 58 21632 [I 5: 312 13024 [Ljava.lang.Object; 6: 32 10240 <objArrayKlassKlass> 7: 42 4032 java.lang.Class 8: 47 3384 java.lang.reflect.Field 9: 11 1728 <constMethodKlass> 10: 48 1648 [Ljava.lang.String; 11: 45 1472 <symbolKlass> TrackbacksThe trackback URL for this entry is: http://devoteinjava.spaces.live.com/blog/cns!908208BAA1B1702!170.trak Weblogs that reference this entry
|
|
|