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

Showing Answers 1 - 5 of 5 Answers

andrew

  • Aug 1st, 2005
 

What are the objects that are not subject to garbage collection?

  Was this answer useful?  Yes

Harish

  • Aug 25th, 2005
 

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

  Was this answer useful?  Yes

Buddhadev

  • Sep 29th, 2005
 

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...

  Was this answer useful?  Yes

dgiscool

  • Oct 9th, 2005
 

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...


Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions