• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

can agrbage collection be forced???

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following are true about garbage collection?

a] we can set the object references to null to ensure that garbage collection will run perfectly
b] Local variables are candidate for garbage collection when the method returns (finished).
c] To use finalize() you must use a try-catch block or rethrow the error object.
d] The JVM will never run out of memory
e] Garbage collection mechanism cannot be forced

ans is a,c,e but garbage colection can be forced by calling System.gc() therefore e can't be true
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bzzt... sorry but thanks for playing.
Actually System.gc() is only a suggestion to run garbage collection. The system will decide for itself whether to ignore your suggestion. And this makes sense since garbage collection can be time consuming and someone else may not be thrilled with your running garbage collection and holding up the JVM in the middle of their process.
 
Hot dog! An advertiser loves us THIS much:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic