Followers

Tuesday, August 6, 2013

Garbage Collection Notes



    The heap size influences the following:

– The GC frequency and the pause during collections
– The number of short and long term objects
– Fragmentation and locality problems

    An undersized heap with the concurrent collector leads to full GCs with an increase in load and also fragmentation problems.

    An oversized heap leads to increased collection times and locality problems (smear problem).

    The permanent generation may be a factor on applications that dynamically generate and load many classes (JSP and CFM application servers).

    Size the heap to handle peak and burst loads.

    Be sure to increase the memory as you increase the number of processors, since allocation can be parallelized.

    Configure as much memory as possible to the virtual machine unless you have problems with pauses.

    Do not choose a maximum value for the heap unless you know that the heap is greater than the default maximum heap size.

 – Explicit garbage collection calls (System.gc())  force a major collection.

    Measure the effectiveness of explicit GC calls by disabling them using the following option:

 -XX:+DisableExplicitGC

    Increase the MaxPermSize to accommodate the dynamically generated classes.

-XX:MaxPermSize=nnn

    Use -XX:+AggressiveHeap for throughput applications.

    Applications that rely on finalization (finalize method) will cause lag in garbage collection. Try reducing the dependency on finalization.

    The more CPUs, the more the advantages of the concurrent collector increase.

    The increase in the lifetime of objects increases the frequency of collection as live objects take heap space. So keep live objects to the needed minimum.

– Set a limit for pooled objects and do not set this value too high.

    Avoid setting old generation size too small as this may result in undersized heaps.

– An undersized heap may reduce collection time and lead to fragmentation and frequent full GCs.

    Increase young generation to decrease the frequency of collection, but this will increase pause. So choose a size for the young generation where the pause is tolerable.

    An increase in load will fill up the heap faster and this will increase the collection frequency. To reduce the collection frequency, increase the heap size.

    Use the default serial collector for smaller applications.

    For larger applications hosted on WebLogic Server, use the throughput collector.

-XX:+UseParallelGC

Read more: http://www.wikiconsole.com/wiki/?p=4662#ixzz2bF1JyO2c

1 comment: