l Garbage Collection:
l 讓物件能”有機會”被garbage collected的方法:
n nulling a reference
n reassigning a reference value
n isolating a reference
l gc runs in low memory situations。VM將此thread的priority設為0(最低)。
l 當系統有其它thread在運作時,就不會進行GC。
l 只有gc可以destroy 一個object。
l Runtime.getRuntime().gc() / System.gc()
l finaliaze被呼叫的時機為真正做gc之前。
l The finalize method of each instance can only run once
l String s = “Hello”; String s = nothing; è is not garbage collected
String s = new String(“Hello”); String s = nothing; è is garbage collected
来自:【 Garfield 的 SCJP 閱讀筆記 】