I noticed something interesting from Java's Performance FAQ.  It has
a number of VM tuning strategies that can be used by HotSpot 1.3+.

The faq (http://java.sun.com/docs/hotspot/PerformanceFAQ.html) has
an entry for pooling, calling System.gc(), etc.

QUESTION:
Should I pool objects to help GC? Should I call System.gc() periodically?
Should I warm up my loops first do that Hotspot will compile them?

ANSWER:

The answer to all these questions is No!

Pooling objects will cause them to live longer than necessary. The
garbage collection methods will be much more efficient if you let it
do the memory management. We strongly advise taking out object pools.

[ Editorial note:  Component pooling and connection pooling have real
   measured performance gains.  These are due to the fact that they are
   expensive to create.  The comment is more for simple objects that are
   pooled. ]

Don't call System.gc(), HotSpot will make the determination of when its
appropriate and will generally do a much better job.  If you are having
problems with the pause times for garbage collection or it taking too long,
then see the pause time question above.

[ Editorial note: There is an option to disable explicit garbage collecting
   calls to test this statement. (-XX:-DisableExplicitGC) ]

Warming up loops for HotSpot is not necessary.  HotSpot now contains On
Stack Replacement technology which will compile a running (interpreted)
method and replace it while it is still running in a loop.  No need to
waste your application's time warming up seemingly infinite (or very long
running) loops in order to get better application performance.

[ Editorial note: This does not apply to benchmarking.  Do warm up the
   VM by running your benchmark for a period of time before collecting
   results. ]


-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to