Manning's Countdown to 2014
. Use discount code crdotd14 all month for 50% off every deal.
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.
It is sorta covered in the
JavaRanch Style Guide
subject: When are inner class objects garbage collected
Referencing an inner class's outer class
Static reference and GC
garbage collection of static members
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013