There is a difference between the automatic collection of the Sun JVM and the programmatic explicit invocation of System.GC ().
Automatically recycled thread level is the lowest, if the system is more and more busy, more and more pressure, then automatically recycled threads will be running the opportunity to become smaller, or even not run, the result is that memory can not be released;
The use of programming calls to System.GC () is not recommended because garbage collection the system hangs, and the programming call is usually handled regularly, and the user line level is higher than 5, that is sure to be run (this I used, the recovery effect is obvious, J2ME friend will certainly have a deeper understanding), So the system will also be suspended periodically, it will affect the system's response, but it is not obvious.
Second, to sum up, in the appropriate time to call System.GC () two times is appropriate, pay attention to "two" is only personal experience, we can test.
Third, in addition, the sun JVM is only suitable for the development environment, that is, start speed reading faster,
In a product or production environment, I recommend that you use the Jrocket VM, which can be downloaded free of charge from the official website of BEA, which not only has parallel and generational garbage collection (that is, the garbage collection thread and the user thread have the same priority and can run simultaneously without suspending the system , garbage collection has a finer granularity level, and can greatly improve the performance of the system.