How all can you free memory

Showing Answers 1 - 29 of 29 Answers

Vrushali Talokar

  • Jun 10th, 2005
 

With the help of finalize() method.

  Was this answer useful?  Yes

Arundathi

  • Jul 1st, 2005
 

If a programmer really wants to explicitly request a garbage collection at some point, System.gc() or Runtime.gc() can be invoked, which will fire off a garbage collection at that time.  

satheesh

  • Sep 19th, 2005
 

we can use system.gc() or runtime.gc() method to garbage collect but note one point that its not sure that it will garbage collect the object Better assign Null to unused objects

  Was this answer useful?  Yes

kiran

  • Jun 15th, 2006
 

 by using or call the finalise method  to free the objects or variables which is not usefull

  Was this answer useful?  Yes

jFreak

  • Apr 10th, 2007
 

All that a programmer can do is make an effort to free memory by nullifying references, then too Garbage Collection is not in his hands and GC takes place ar the JVM's will.

Calling the gc() method at any point in the program is also simply a request to the JVM to perform GC....there is no guarantee that it will obey fulfil the request!

--S

  Was this answer useful?  Yes

nakul rajput

  • Apr 16th, 2007
 

memory can not be free by the programmer in java.it is automatically managed by the JVM.after all it depends upon the jvm .garbage collection is not gurented in java.the only thing the programmer can do the requst to jvm to free the memory by using
system.gc(),but its still not gurented.

  Was this answer useful?  Yes

Still you are not sure that the GC will free memory, the only way to ensure that at least some percentage of freeing memory is done we need to- Use finalize methods and call relevent API methods like close(),dispose(),release() to free memory- Do not call Runtime.gc() as its not guranteeeing metod frreeing

  Was this answer useful?  Yes

Amit Patil

  • Sep 17th, 2007
 

System.gc() is only a suggestion to JVM to run the garbage collector. There is absolute no guarantee when and if it would be exceute. Programmer has no way of invoking the garbage collector. Setting all the references of object to null makes it a candidate for be garbage collection during garbage collection cycle

we r not responsible for removing the memory. it is the jvm responsibulity.if u want to free some memory then call the Finalize() then it willgive the instructions to jvm that object has no longer use and we can reslese the resorces which are allready serving to the particular object 

  Was this answer useful?  Yes

Augustine Vineeth

  • Nov 16th, 2007
 

we can use System.gc() and System.runFinilize() to request garbage collection

  Was this answer useful?  Yes

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