Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection doubt

 
Mahmoud Metwaly
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming we have the following method



Now by exiting this method, how many objects are eligible for garbage collection 4 OR 5 (if we are going to count 4 objects of the array + the array object itself)?


Thanks in advance
 
Bob Ruth
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to take a guess and say one.

Here's why I say that: the statement instantiates an array large enough to hold four String references..... and then nulls them all. They do not contain instances of strings yet. So I think that the only object there is the array.
[ July 29, 2008: Message edited by: Bob Ruth ]
 
Lino Larios
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that one only object the array , because the array is just holding 4 references variables
[ July 29, 2008: Message edited by: Lino Larios ]
 
Ronald Schild
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only the array object. All the references in the array are set to null as default value, and no String objects are created.
 
Vinod Kumar Kommineni
Ranch Hand
Posts: 54
Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya its only one object ... since they are not intialised to refer any object
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic