• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About gc

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How we come to know that object is Garbej collected? But i know runtime.gc take care but programatically how can we come to know with garanty...?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're asking "how will we know if an object is eliminated by the garbage collector", the answer is, quite frankly, that you won't. Garbage collectors work like this:

1) Unmark all resources
2) Check every variable in use
3) If a variable points to object x, mark it
4) Delete all unmarked resources
5) Reorganize data to eliminate memory fragmentation

In short, in order to determine whether object x has been deleted, you'd need a reference to object x. If any reference to object x exists, the garbage collector leaves it alone. It makes a paradox.

You'll just have to trust that at some point it will be deleted. That's one drawback to GC.
reply
    Bookmark Topic Watch Topic
  • New Topic