Java?????????????
???????????? ???????[ 2013/1/7 10:10:24 ] ????????
?????????????size?????final???Σ????????????????????????????????????????????????????Щ????????????????????С????????????????????????????????????????????????С?????????????????String???????????String?? intern()??JVM???ж???????????String???????????????У????У??????????????????????????????????????????????????С??????JDK??java.io.ObjectStreamField????δ???
....
ObjectStreamField(Field field?? boolean unshared?? boolean showType) {
this.field = field;
this.unshared = unshared;
name = field.getName();
Class ftype = field.getType();
type = (showType || ftype.isPrimitive()) ? ftype : Object.class;
signature = ObjectStreamClass.getClassSignature(ftype).intern();
}
??????δ???????????????????????HotSpot?в???е????????????????????????????С?
????3??????????????????????????JVM???????????????JDK1.4??????NIO?У???????Ч??R/W???????????Ч??R/W?????????????????????????????????????????????棬??????????????????????JVM??棬???JVM??????????????????????????????????????JVM???DirectByteBuffer?????????檔
????4???????????????????????JVM?е??????????????????????????GC???????????????н??е?????е?java??????????????????JVM?д???????????????????????????????????????????????????????
????java????????????????????????????????????java???????????
???????????????????????????????
?????????????????????????????ν????????????????????????????????б????????????????????????????′???
...
public void test()
{
int x=1;
char y='a';
long z=10L;
}
????????x y z?????????????????佫??test()??????????з???test()????????????????е????????????????棬????????δ???
....
public void test2()
{
Date d = new Date();
System.out.println("Now is "+d);
}
????????????????????????????????????Date d???????new Date??Date d?????????????date??????????????????????????int x????????????????????????????????java???????????int??????????4????????????????????????????4?????????JVM?е???0???????δ??????????????κβ????????????????????
??????????и????d = new Date()??????d??????new Date??????????????????????????????????????new Date()????jvm??heap?з???????????????????????????????????????????????????????Date d????????????test2()????????????????????????????????????????????????
??????????????????????????????????????new Date()??C++???new??????????????????heap?з????????????????????????????????????????????????????C++?б?????????????????delete?????java?????????????GC?????????????????????????????????????Щ?????????????????????ж???Щ??????????????????????????·?????
??????????ü????????????????????java ?????????????????????????????????????????????÷?????????????????????????????????ü??????????????????1?????y?????1????Щ??????????0??????ж??????????????????????ж?????????ж???Ч???????????????????????????????′???
package com.mail.czp;
import java.util.ArrayList;
import java.util.List;
public class Test {
private byte[] buffer;
private List ls;
public Test() {
this.buffer = new byte[4*1024*1024];
this.ls = new ArrayList();
}
private List getList() {
return ls;
}
public static void main(String[] args) {
Test t1 = new Test();
Test t2 = new Test();
t1.getList().add(t2);
t2.getList().add(t1);
t1 = t2 = null;
Test t3 = new Test();
System.out.println(t3);
}
}
??????
???·???
??????????????????
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