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 閱讀筆記 】
博客介绍了Java垃圾回收(GC)相关内容。阐述了让对象有机会被GC的方法,如清空引用、重新赋值引用等。指出GC在内存不足时运行,VM将其线程优先级设为最低,系统有其他线程运作时不进行GC,只有GC能销毁对象,还提及了调用GC的方法及finalize方法的调用时机。
141

被折叠的 条评论
为什么被折叠?



