I think if an object gets created locally within a method and is never leaked outside then that object will be eligible for garbage collection as soon as that method executed is completed.
But I am confused because I read that there are 4 GC roots - and one of then is the thread object, so I am confused that is it the case that method local objects will become eligible for garbage collection only when the thread in which it got created is complete and the GC Root of that thread is taken off?
Also, if someone can throw some light on how method local objects are linked to stack area of the heap.
PLEASE NOTE that I have read about GC of method local objects but nowhere I got a clear and detailed answer so I raised this question.