Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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

Garbage Collection

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following statements related to Garbage Collection are correct. Select all correct answers.
A. It is possible for a program to free memory at a given time.
B. Garbage Collection feature of Java ensures that the program never runs out of memory.
C.It is possible for a program to make an object available for Garbage Collection.
D. The finalize method of an object is invoked before garbage collection is performed on the object.
Correct Answers: C and D
Could anyone explain why B is not included in the answers?
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Garbage collection does not ensure a program never runs out of memory. It's still possible gc may never run during a program execution, if badly written - the program will definitely run out of memory.

------------------
Velmurugan Periasamy
Sun Certified Java Programmer
----------------------
Study notes for Sun Java Certification
http://www.geocities.com/velmurugan_p/
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
B. Garbage Collection feature of Java ENSURES(?) that the program never runs out of memory.
"Java performs GC for you and eliminates the need to free objects explicitly." pg. 47
"GC is not a Guarnatee that memory will always be available
for new objects. You could create objects indefinitely, place them in lists and continue ...
GC solves many, but not all memory allocation problems." pg. 48

Java ProgLang(2nd Edition) Arnold,Gosling
 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I was thinking that garbage collection cleans up the objects that do not have a reference and thus makes sure that
the system has enough memory especially when the system is low on resources.
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic