Hello!

Java does not guarantee in any way that the garbage collector will run at
the time of your call by the programmer.

If you run out of memory, I would look at the code to see if they are
throwing good objects that are no longer used.

Regards.

Gustavo Echenique

-----Mensaje original-----
De: [email protected]
[mailto:[email protected]] En nombre de Shiv
Shankar
Enviado el: sábado, 19 de junio de 2010 05:41 p.m.
Para: Java Programming Online Training Course By Sang Shin
Asunto: [java programming] Why gc() method has been exposed ?

Hi,
I am confused, why JVM is providing its own garbage collector to 
programmer. If we call gc() explicitly and it will get decided by JVM 
whether to call it or not. Then what is the use of it for programmer.
Is JVM is not smart enough to handle the gc() call when going out of 
memory. i.e. (OutOfMemoryException)

   If I write a code and I have doubt that memory is not available i 
need to handle exception in that case. And I (programmer) need to call 
gc() method to free some memory from objects eligible for garbage 
collection.
   If JVM is smart enough it should handle OutOfMemoryException it self 
and call gc() method.

   One more doubt. Does JVM call gc() before throwing OutOfMemoryException.

-- 
With Regards,
Shiv Shankar

-- 
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to