aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "garbage collection" Watch "garbage collection" New topic
Author

garbage collection

maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186
according to k and B if an objct is returning a value from a method it is not eligible for garbage collection right???then why is rg getting eligible???
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
what is happening after the method returns


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

curve karve wrote:according to k and B if an objct is returning a value from a method it is not eligible for garbage collection right???

Yes True.

curve karve wrote:
then why is rg getting eligible???

because method is returning null object.


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Phungsuk Wangdu
Ranch Hand

Joined: Nov 04, 2009
Posts: 114
another view could be because all are automatic variables aka local variables so after method completes all local variables are flushed only objects creted remain but still the reference is nulled so it is eligible for gc
Phungsuk Wangdu
Ranch Hand

Joined: Nov 04, 2009
Posts: 114
well i think object dg could also be eligible for GC wat you say Minhaj
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
ya true...minhaj is right..i didnt see that
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
you are returning rg here...rg is null here...the two variables of the array are local to the array..they will be destroyed after the ethod returns...no one refers to the object anymore..so the object is eligible for gc
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

James Carter wrote:well i think object dg could also be eligible for GC wat you say Minhaj

i mean to say getIt() will return a null reference.
Phungsuk Wangdu
Ranch Hand

Joined: Nov 04, 2009
Posts: 114
YES that is true but dg must also be eligible for gc i guess ? it could be right or wrong
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186
ok..got it..its only if the value rg was not referring to null then it was not eligible for garbage collection???
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
actually if the method was returning soemthing and something was taking that value only then it wont be eligible for gc
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

James Carter wrote:YES that is true but dg must also be eligible for gc i guess ? it could be right or wrong

yes off course think about the method level variables.
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186
hey dg wont be eligible ...i feel because it pointing to Integer(3)....why will it get eligible....or just because of second last line assignment???m getting confused???
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
please dont use quote tags when you want to say or ask something.

all the method local objects are eligible for gc after the method is complete unless it returns these object references and they have some live references.


SCJP 1.6 96%
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186
hey thanks neha
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
only one girl is required to remove all the confusion between so many idiot men
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
thanks Ankur
but none is idiot here..its just what clicks your mind and when.
you cleared scjp with 91%, how can you say that?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: garbage collection