Hi,
I'm not an expert on this, but I have read the following in an Perf Guide written by HP.
--
Should we see an entry in this data that has the content:
揊ull GC required ?reason : call to System.gc() or Runtime.gc()?br>
then we know that either the user抯 Java code or some library or infrastructure code being used in the application is making an explicit call to the garbage collector. This should never be done. We can cure this problem by removing the call to System.gc() or Runtime.gc() from the code, or by overriding it with the JVM option 朮X:+DisableExplicitGC, as follows:
So...I guess you might want to consider using this call?
Found this in another thread.
-
In the Java source code you can find the following comment:
// We don't want shrink all the way back to initSize if people call
// System.gc(), because some programs do that between "phases" and then
// we'd just have to grow the heap up again for the next phase. So we
// damp the shrinking: 0% on the first call, 10% on the second call, 40%
// on the third call, and 100% by the fourth call. But if we recompute
// size without shrinking, it goes back to 0%.
--
> I thought that it suggests that the JVM run a
> garbage collection.
>
> [url]http://java.sun.com/j2se/1.5.0/docs/api/java/lang
> /System.html#gc()[/url]
>
As I said, in every Sun VM back to at least 1.3 it does collect garbage when you call it.
The VMs by other vendors might choose to do it differently.
If you use Sun's HotSpot 1.5.0 JVM (or later) with the -XX:+UseConcurrentMarkSweepGC (low-latency) garbage collector, you can use the additional flag -XX:+ExplicitGCInvokesConcurrent to have calls to System.gc() initiate a concurrent collection, rather than cause a stop-the-world compacting collection, which calling System.gc() usually does. Most people who run the low-latency collector are trying to avoid the pauses caused by compacting collections.
If you have some annoying third-party library that calls System.gc() and that upsets your application's performance, you can use the additional flag -XX:+DisableExplicitGC to make calls to System.gc() into no-ops. That works with whatever collector you are using.