???????????StackOverflow?????????????????????????Java??д??λ??????й?????????
????Q???????μ????????????????????д?????????й???Java?????????????????·????У??????
????A1????????2?????????????????й?????????????????Щ?????????????????????????У?:
??????ó????????????????е??????????????????????????????й?????
??????????????????????????????壩?????????
?????????????????棨????new byte[1000000]?????????????????洢??????????????ThreadLocal?д洢??????????á????????????new byte[1000000]??????(?????й????????)????????????????й?????
??????????????????????????????????????
?????????????衣
???????????????????????????????ThreadLocal?е?洢????????????ThreadLocal???и????????????????????????????????????????????????????????????????????????????GC???????ThreadLocal?д洢????檔????JVM???????Java????????????????permgen???????GC?????????????????????й???
????????й??????????????????????2??????κ?????????ThreadLocal????ó????????????????Tomcat???????????????й??????????????????????????????????????2?????????????μ????????????
????A2??
??????????????????
????class MemorableClass {
????static final ArrayList list = new ArrayList(100);
????}
???????ó????????String.intern()
String str=readString(); // read lengthy string any source db??textbox/jsp etc..
// This will place the string in memory pool from which you cant remove
str.intern();
try {
BufferedReader br = new BufferedReader(new FileReader(inputFile));
...
...
} catch (Exception e) {
e.printStacktrace();
}
????δ???????
try {
Connection conn = ConnectionFactory.getConnection();
...
...
} catch (Exception e) {
e.printStacktrace();
}
????JVM??GC?????????
???????????native???????????檔
????web?????application??Χ????????δ????????????????
????getServletContext().setAttribute(“SOME_MAP”?? map);
????web?????session??Χ?????δ?Ч?????????????
????session.setAttribute(“SOME_MAP”?? map);
???????????????????JVM???
????????IBM JDK??noclassgc????????????????????
????A3?????HashSetδ??????(????δ???)hashCode()????equals()??????????г???????“????”?????????????????????ú?????????????С????????????????????????Щ????