• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

garbage collection  RSS feed

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case of nested dataobject, is it sufficient to setthe parent object to null after I am done with the data. Or I have to indivially set each object to null.
Thanks
Sri
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you provide some example code?
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DataObjectOne small = new DataObjectOne();

DataObjectBig big = DataObjectBig();
big.setSmall(small);
After I am done with "big", is it sufficient to make the reference of big to null
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. But if "big" is a local variable that's going to go out of scope soon, you don't even need to do that.
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what if "big" is a instance variable. when it will be garbage collected. Or how I can I make the "big" instance eligible for garbage collection
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making an Object(class) as NULL, which has many instance variables declared as new obejcts.
Will that Obejct and and all the instance variable objects will be eligible for garbage collection?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sri Rangan:
I am making an Object(class) as NULL, which has many instance variables declared as new obejcts.
Will that Obejct and and all the instance variable objects will be eligible for garbage collection?


Yes, unless they are still referenced by other objects in use.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!