hi all im preparing for the SCJP exam and would like to know how to find out when an object/variable is available for garbage collection . This has been a problem for me because i can never say which line is the legal one for Garbage collection in the mock test that i have been giving . please let me know regards pranav
This is one of the beauties of java , u DONT HAVE TO WORRY ABOUT GARBAGE COLLECTION 'COZ JVM TAKES CARE OF IT . We can not force gabage coll. we can only suggest by giving System.gc(). util there is a reference pointing to a object or the object is pointing to something it cant be garbage collected.
hi all, how do we know that a reference is not pointing to some location in the memory. the simplest way to find out is when it equals null eg. Gc gc = new Gc(); gc=null;///after this line the object is not pointing anywhere and is eligible for garbage collection. but there are many other cases when the onject becomes eligible for garbage collection.. can anybody please explian ... sanjeev