???????Java String#intern()??????
???????????? ???????[ 2015/3/20 15:17:53 ] ????????Java ??????? ??? ?????
????????????Java??string.intern()????????????????????????в??????????????????????????????????????????????д???????????????????
?????????????????????????С??HashMap??????????????1009?? ??Java7u40???????????????60013????Java6???У?????????????????Perm???????Java7????????????????????Heap??????棬?????????????????????????????????Java6??Java7????????汾???μ????????????
???????????
public class StringPoolTest {
public void testStringPoolWithLongString(){
long i=0;
while(true){
String longString = "This is a very long string?? very very long string to test the gc behavior of the string constant pool"+i;
longString.intern();
i++;
}
}
public static void main(String[] args){
StringPoolTest stringPoolTest = new StringPoolTest();
stringPoolTest.testStringPoolWithLongString();
}
}
???????????????????????????????????????????i?????????????????main???????????
????Java 6
??????????e汾Jdk1.6.0_29????ó?????Java VisualVM?????????????Perm?????????GC?????????????????????????????Perm???????Perm????????????JVM??????????????е????????????????
????Java 7
???????棬?????л???Jdk1.7.0_67????ó??????????Perm????????????????????г??????????????
????????Heap????μ???????????????????GC
????????
????????Perm????С?????????????м??MB????????????Java6?1????String.intern()?????????string-intern-in-java-6-7-8????????????????Java6???′??????intern()????????????????????????п??????OOM????????Java7??????????????????????Heap???Heap?????С???????????????????С????????Java7?????String.intern()?????Ч????????String???????????á?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11