• 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

assist in finding no of objects Garbage collected

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anything easy to follow in answering questions relating to no. of objects garbage collected?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can determine the number of objects eligible for garbage collection, but I don't know if you can determine the number actually collected. (If you can, it won't be on the exam.)

For help in determining what's eligible, try searching this forum for "garbage collection" or "island of isolated objects". You will get a lot of hits, so you might want to limit the search to the last 30 days. One recent thread that should come up is this one.
[ December 27, 2006: Message edited by: marc weber ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically, to show that an object is eligible for garbage collection, you have to prove that there are no references to the object from any live threads. Not always an easy task.

From the topic that Marc mentioned, you can see that a visual approach can be beneficial, especially for the relatively small examples. Compile and run the code. You also can override finalize() in classes whose objects become garbage collection candidates and get them to print something out when they have been collected. You can call System.gc() in your test programs. But be aware that these techniques are not 100% reliable in finding garbage collectable objects.

The GC (and Thread) questions are good for testing your analytical capabilities.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic