• Post Reply Bookmark Topic Watch Topic
  • New Topic

GC of Array elements  RSS feed

 
Apan Raj
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider an array of Objects. What happens to the elements of the array if its reference is made null. Will making the array elements null individually before making the array null make any difference from memory management point of view ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens to the elements depends on whether or not other references to them exist elsewhere in the program. There is nothing magic about a reference in an array versus any other reference. Making the references null won't do a thing but chew up CPU time.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!