2016年3月9日 星期三

關於資源回收題目

Which statement is true?

A. Programs will not run out of memory.
B. Objects that will never again be used are eligible for garbage collection.
C. Objects that are referred to by other objects will never be garbage collected.
D. Objects that can be reached from a live thread will never be garbage collected.

A 是錯的,GC不能保證可以釋放出足夠的記憶體。
B 是錯的,陷阱答案,"never again be used"=>不再使用的物件並不代表不被參考到的物件
(有一說法是可能會在finalize()中重新被參考到,但我認為Finalize()被呼叫也就代表GC已經被啟動了,個人看法。)
C 是錯的,考孤島型的參照一樣會被回收。
D 是對的

沒有留言:

張貼留言