Java???????String???????????
???????????? ???????[ 2015/8/17 10:29:30 ] ??????????????????? ???????
???????Heap????Java???Java Heap????Java????????????????д????顣Java????????????????????????????????????????????????????????е??????????????????????棬????????????????????????Stack???з??????????String s = new String(“s”)?????????????????????棺??????String?????????棬??????????????????????????????????????棬??????????
????JAVA??????????????з?????????????????????????????????????Java??????????????????????????????????????????????????????????е????????????????????棬????????????????????????????????Garbage Collection????????????ò?????
????-Xms — ????????????С
????-Xmx — ??????????
????-XX:MaxTenuringThreshold — ????????????????д??????
????-XX:PretenureSizeThreshold — ???ó????????С?????????????????????
????Java????????????????????????????????“GC ??”??Garbage Collectioned Heap???????????????????????????????????????????Java?????????????????????Young Generation???????????Old Generation??????????????????????????????????????y???????????????(young generation)???????????????????minor collection???????????(old generation)??????????????????major collection??????????????GC????????????ж????????飬????ó??????????????????????????????????????????????治??????????????????GC??Young GC????????????GC??????????????????????????? ?????????????????????????GC??Full GC????
???????????????ж?????????????????????????Permanent Generation??????????????????Java????????????????????е???????????????????????????jvm??????????????????Щ????????????????????????????????????????Щ??????????????????GC???????????????????PermGen Space?????????????????????????к??CLASS?????????????PermGen Space????????????ò?????
????-XX:PermSize –????Perm????????С
????-XX:MaxPermSize –????Perm??????
????????????Young Generation????????Eden????Survivor????Survivor???з??From Space??To Space??Eden?????????????????????????£?From Space??To Space???????С????JVM????Minor GC?????Eden?л????????????Survivor???У?????Survivor???л????????????Tenured???С???????GC???£?JVM???????GCЧ??? ??Survivor?????From Space??To Space??????????????????????????????????????????С??????2??????????
????-Xmn — ??????????????С??
????-XX:SurvivorRatio — ????Eden??Survivor?????С????
???????????Old Generation???? ?? OLD ?????????? JVM ???? OLD ?????? major collection????????????????Survivor??OLD????????????Eden???????????????????JVM?????Eden??????????????????????”Out of memory????” ??
????????String???????????
???????????Java???????????????Java??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????е??????????
???????????????
?????????????????3??????????
????char???????????????γ???????????????????????????????????char????bool???
????returnAddress?????????Java????????????????????????????Java?????е?finally???
????String?????????????λ???yes?????????????????????????????濪???String????????
????1??String?????
??????String???????????????????λ?“Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings.Because String objects are immutable they can be shared.”????仰????????String?????????????String????????(immutable)????????????????(can be shared)??
????????????String???????final???η?????????String??????????String????????е??
??????????String????????????壬???????????????String????????(immutable)??
????private final char value[];
????private final int count;
?????????????String???concat?????????÷???????????????????????????value?????????????????????????????????????????buf?????????????value?е????copy??buf????????????concat?????????copy??buf?????????????buf?а?????concat???????????????????????????????value????final????????value???buf???????this???????????б??????????μ?String??????????????????????????value??final?????????????????????????????buf????????????“return new String(0?? count + otherLen?? buf);”??????String??concat???????????????????new???String?????????????????????
???????String???????????飬???????1???????????У?2?????????(immutable)??
??????
???·???
??????????????????
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