GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 27 of 921    Print  
Does garbage collection guarantee that a program will not run out of memory
Garbage collection does not guarantee that a program will not run out of memory. It ispossible for programs to use up memory resources faster than they are garbage collected.It is also possible for programs to create objects that are not subject to garbage collection


  
Total Answers and Comments: 4 Last Update: October 09, 2005   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 01, 2005 21:42:58   #1  
andrew        

RE: Does garbage collection guarantee that a program will not run out of memory
What are the objects that are not subject to garbage collection?
 
Is this answer useful? Yes | No
August 25, 2005 04:26:49   #2  
Harish        

RE: Does garbage collection guarantee that a program will not run out of memory
How we can create objects that are not subject to garbage collection? 
 
Plz answer me soon...

 
Is this answer useful? Yes | No
September 29, 2005 03:26:08   #3  
Buddhadev        

RE: Does garbage collection guarantee that a program will not run out of memory

the logic behind the gerbage collection is that , the JVM look for the object reference that are not in used and then the JVM mark them for gerbage collection and remove them for better memory management.

So if we want  a object that should not subject to gerbage collection, then we have to use the finalized method and re initiate the object which we don't want to be gerbage collected.

because when first time the JVM mark the object as aligible for gerbage collection, it will first call the finalized method og that class. and as we re instanciate the object in the finalized method the object will not subject to gerbage collection.

Harish Wrote: How we can create objects that are not subject to garbage collection? 
 
Plz answer me soon...


 
Is this answer useful? Yes | No
October 09, 2005 17:08:08   #4  
dgiscool Member Since: October 2005   Contribution: 1    

RE: Does garbage collection guarantee that a program will not run out of memory
The object is eligible for garbage collection only if there is no strong reference to the object. An exception to this is island of references(where all objects point to each other).And you should never write your significant code in the object's finalise method because you can never be very sure that it will run. Finalise method runs only once in the life-time of an object. So even if you re-initialise an object in its finalize code, it can become eligible for garbage collection(if there is no strong reference to the object) and its finalise method won't be called again.Buddhadev Wrote:

the logic behind the gerbage collection is that , the JVM look for the object reference that are not in used and then the JVM mark them for gerbage collection and remove them for better memory management.

So if we want a object that should not subject to gerbage collection, then we have to use the finalized method and re initiate the object which we don't want to be gerbage collected.

because when first time the JVM mark the object as aligible for gerbage collection, it will first call the finalized method og that class. and as we re instanciate the object in the finalized method the object will not subject to gerbage collection.

Harish Wrote: How we can create objects that are not subject to garbage collection?

Plz answer me soon...



 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape