• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java Be the Garbage Collector  RSS feed

 
David Busby
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the main method, what does GC gc1; do?

In class doStuff2, what does GC localGC do?
 
Mohamed Sanaulla
Bartender
Posts: 3179
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the code.
 
David Busby
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it creates a reference to a GC type of object, although it does not create one. It's like giving you a blank address card, saying "This WILL hold the address to a restaurant, somday"
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you analyze reference of each object -

gc1 --> null
gc2 --> some object on heap
gc3 --> some object on heap
gc4 --> gc3

gc1 --> reference to object returned by doStuff --> create localGC (--> refer some object on heap) ---> passing same reference to doStuff2 (it does nothing with it) --> return the reference of localGC.
so overall -

gc1 --> refere to same object which localGC was assigned in dostuff method.


Garbage Collector and finalize
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!