Of course that Java will try to free memory before throwing
OutOfMemoryException.

gc() method is here for convenience. It is very rarely used. But
consider use case in which you have memory intensive application. And
it runs in intervals. During pause interval you can use this time to
say to JVM / if you need, now is time to garbage collect, since this
will now have no impact on my performance.
JVM can use this time, but it is not required to do so.

When you see applications that create lots of garbage during their
runtime, but you also nee them to respond fast, GC run can slow you
down (measured in seconds). This can have an impact on your
responsiveness to clients. In that case you can tune GC (see various -
X or -XX options for JVM).

Hope this helps, since GC is a topic for a book...

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