A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
When are inner class objects garbage collected
Joined: Oct 06, 2003
Dec 11, 2003 03:19:00
I have a question.
Will an inner class object be garbage collected before the outer class object ?
a) in the case of static nested classes
b) in the case of nonstatic inner classes
Joined: Feb 27, 2002
Dec 11, 2003 03:35:00
If the inner goes out of scope inner class will be gc 'ed. If the outer class goes out of scope it will be garbage collected.
Joined: Aug 25, 2003
Dec 11, 2003 07:35:00
Inner class objects are no different from any other object on the heap: an object becomes available to GC when no live thread can access it through the object reference.
I agree. Here's the link:
subject: When are inner class objects garbage collected
Static reference and GC
Referencing an inner class's outer class
garbage collection of static members
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014