Discussion :: Garbage Collections
-
Which statement is true?
A.
Calling Runtime.gc() will cause eligible objects to be garbage collected.
|
B.
The garbage collector uses a mark and sweep algorithm.
|
C.
If an object can be accessed from a live thread, it can't be garbage collected.
|
D.
If object 1 refers to object 2, then object 2 can't be garbage collected.
|
Answer : Option C
Explanation :
This is a great way to think about when objects can be garbage collected.
Option A and B assume guarantees that the garbage collector never makes.
Option D is wrong because of the now famous islands of isolation scenario.
Be The First To Comment