• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

GC

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Which of the follo stmts are true.
1.You can directly free the memory allocated by an object.
2.You can directly run the garbage collector whenever you want to and it will be schedule in due time..
3.The garbage collector informs your object when it is about to be garbage collected.
4.The garbage collector reclaims an object’s memory as soon as it becomes a candidate for garbage collection.
5.The garbage collector runs in low-memory situations.
the ans given are 2,3,5.
I doubt the option 3 because it is unknown when an object would be garbage collected. Pl explain this.
-Sanjana
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The finalize() method of an Object is called when it is garbage collected.
Angel
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can the Option 2 be correct? My understanding is that, Garbage collection can only be suggested and it is at the sole discretion of the JVM to schedule the garbage collector in low-memory situations. Can any one explain on this?
Thanks very much,
Rama
 
Angel Dobbs-Sciortino
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think when it says "it will be schedule in due time", it means you can run System.gc() and *suggest* that garbage be collected. The actual timing of the collection is up to the JVM.
Angel
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


2.You can directly run the garbage collector whenever you want to and it will be schedule in due time.


I believe this statement is wrong, because you can't directly run garbage collection, you simply request to run it, afterwards you'll have to wait for the JVM to honor your request.
Eventhough the question says "it will be schedule in due time.", the term directly run is not accurate and should be changed to request to run.
 
reply
    Bookmark Topic Watch Topic
  • New Topic