Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

garbage collection

 
Suhita Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
when b1 is eligible 4 garbage collection

[ July 10, 2006: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, please use tags around your code. It makes code so much easier to read.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when b1 is eligible 4 garbage collection


What "4" do you mean? Line 4?

Ha! We have a question here, not a statement.

"When is the object referenced by variable b1 eligible for garbage collection?"

You had me confused there with all this pseudo-speak.

[ July 10, 2006: Message edited by: Barry Gaunt ]
[ July 10, 2006: Message edited by: Barry Gaunt ]
 
Suhita Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, line4
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer is just after the line numbered //2, there is no reference to the Byte("127") object at that point.
 
Mike Noel
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I understanding correct? The original poster thinks that Byte("127") isn't available for GC until after line 4? It seems pretty clear that after line 2 that object is available, just as Barry said.

What is the reasoning you are using that makes you think it would be line 4? Maybe I'm missing something here.

_M_
 
Suhita Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i also think in the same way.but they gave answer as at b1=null it is going to garbage collected
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Byte Object will be eligible for GC after the execution of line 2. If you comment line b2[1] = b1; then same Byte object will be eligible for GC after the execution of line 1.

Naseem
 
Amit Batra
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but they gave answer as at b1=null it is going to garbage collected


Who is saying this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic