Thursday, December 24, 2009

Oracle JRockit : OutOfMemoryError

Oracle JRockit : OutOfMemoryError

Thread Local Area and LargeObjectOrArray


In JRockit, Each thread allocates TLA (Thread Local Area) to store short living objects, and benefits GC to reclaim space. The repective thread can then allocate
objects in its TLA without synchronizing with other threads. If particular TLA size become full, then new TLA will be alotted. In general, we think that by specifying bigger number for TLA we get best performance. But reality is not that case, whenever new thread starts, TLA size has to be reserved with minimum space mentioned in tlasize.



We can specify what could be the largeObject or Array size needs to be stored in TLA, others goes to Heap. Recommendation would be, -XXtlasize:min and -XXlargeObjectLimit has to be equivalent and -XXtlasize:preferred size must to set minimum double the -XXlargeObjectLimit value.



-XXtlasize:min=3k -XXtlasize:preferred=10k -XXlargeObjectLimit=3k

Above configuration tells JVM that 3k objects are larger and it should not go to TLA. Each TLA can grow maximum 10k. If application starts/maintains maximum of 100 threads and all operates on its own data (mean, no synchronization required), then specifying bigger number for TLA, would help to increase the application.



Exception in thread "PoolThread" java.lang.OutOfMemoryError: allocLargeObjectOrArray - Object size: 586154000, Num elements: 586153984
Cause: allocLargeObjectOrArray - Object size: 65552, Num elements: 32768



In the above exception Object Size specifies the size of the Object trying to store in old space with Num elements. This is due to poor garbage collection triggered.



Nursery Size


-Xns option used to specify the size of Nursery. Garbage collection happens quickly in Smaller nursery and larger size takes longer. This size has to be defined based on the application memory usage, and eventually it is Performance Engineer responsibility to set memory settings to make sure that as many object as possible are garbage collected by young collection rather than old collection.Recommended value for this size would be half of the free heap size.



-Xns=100m

-XXkeepAreaRatio:<percentage> used to keep the young and old collection frequency. If ratio high young generation will be triggered often.



Garbage Colletor


JRockit R27.3.0 and later releases offers various types of collector. It is our responsibility to find best suiting option to our application.




Static garbage collector


-Xgc:<strategy>
-Xgc:genpar - generational parallel garbage collector
-Xgc:gencon - To use a generational concurrent garbage collector

-Xgc:singlecon - To use a single-spaced concurrent garbage collector
-Xgc:singlepar - single-spaced parallel garbage collector


Dynamic garbage collector


-XgcPrio:<mode>
-Xgcprio:throughput - gives priority for throughput
-XgcPrio:pausetime -XpauseTarget=40ms - gives priority for pause time
-XgcPrio:deterministic -XpauseTarget:40ms - gives priority for throughput and not crossing pause time


Parallel Mark and Sweep

While garbage collection other Java threads will be paused- genpar and singlepar.



Mostly Concurrent Mark and Sweep

While garbage collection all other JAVA threads will not be paused, if no necessary of synchronization - singlecon and gencon.



For more details, visitOracle JRockit

3 comments:

avhari said...

Very very useful Post

John said...

Where do we set this values?

Anonymous said...

where do we need to set up this parameter ?
-XXtlasize:min=3k -XXtlasize:preferred=10k -XXlargeObjectLimit=3k

Post a Comment

Recent Posts

Unix Commands | List all My Posts

Texts

This blog intended to share the knowledge and contribute to JAVA Community such a way that by providing samples and pointing right documents/webpages. We try to give our knowledege level best and no guarantee can be claimed on truth. Copyright and Terms of Policy refer blogspot.com