What is Jrockit JVM?
Is a high performance JVM developed to ensure reliability, scalability, manageability? It’s an enterprise JVM optimized for inter architectures
How machine code is generated by JVM?
Operations stage – JIT compilation – less effective method compilation when the method is called for the first time
Data Structures stage – Thread monitoring – which all methods are frequently called and looking for hot spots
Transformation stage – Code Optimization – recompiles the commonly executed method again efficiently
How threads are used by the JVM?
Each java threads has a stack to store runtime data. -Xss to set the statck size of the thread object for java application, the default for jvm is 256KB
What are the types of Locks?
Thin lock – thread B spins for short time if the lock is acquired by thread A
Fat lock – if thin lock spins for long time, then the CPU time is utilized by other resources by inflating thin lock to fat lock
Recursive lock – synchronized call gets called by itself
Lazy lock – critical section is checked for this lock by the thread
What do you mean by Lock Chains?
Lock chain – A holds lock1 that B also needs, B holds lock 2 that C needs
Open chain – A depends on B, B depends on C and so on. If Long Open chain then the CPU time is wasted in waiting for locks
Deadlock chain – A depends B, B depends on C, C depends on A
Blocked chain – A depends on B, C depends on B, B depends on A
How memory is managed by JVM?
Most common assumption is that an object is most likely to die shortly after it was created: called infant mortality. Objects that are referenced are called as live objects .The process of finding and freeing the space used by these objects are called as Garbage collections
Heap contains two generations. [Nursery or Young] and Old Spaces
TLA [Thread local Area] – free memory chunks from the heap for java threads for exclusive use
Nursery/young’s space – new objects are allocated here – Eden space. Nursery has kept area for current object allocation before young’s collection
Survivor space – objects survived GC of Eden space
Tenured space – objects existed sometime in survivor space are moved to tenured or old space
Old space – after young’s collection objects are moved here
Perm Space – Area of the VM that is used to store the data structures and class information’s.
-XX:MaxPermSize is used to get rid of outofmemoryerror
While promotion if the memory is less than they are stored within young’s space called fragmented nursery – promotion failure
Fragmentation – when the memory is freed the free space may appear in small chunks in many area so that there might not be a contiguous area for allocation of large objects
Compaction – compressing the live objects together and completely reclaiming the memory
What are the basic GC algorithms?
Mark and Sweep
What are different types of collections?
Serial collection – only one CPU is used for GC, -XX:+UseSerialGC
Parallel Collection – GC is split between different CPU and executed simultaneously, -XX:+UseParallelGC
Stop the world collection – the entire application is completely suspended during the collection
Concurrent collection – one or more GC tasks are done concurrently with few stop the world pauses
Compacting collection – this will compact the entire free space by compressing the live objects
Non compacting collection – will not compact leads to fragmentation
Copying collection – copies the live objects to different area
Parallel Compacting Collection – -XX: +UseParallelOldGC
What are the collectors used?
What are all the performance metrics?
Throughput – % of time not spent in GC
GC overhead – % of time spent in GC
Pause time – unresponsive because of GC
Frequency of collection – how often GC is performed
Memory Footprints – measure of heap size
Promptness – the time between objects GC and memory becomes available
CPU usages – CPU usage in GC
What are the tools to evaluate GC performance?
What is Basic GC tuning?
Throughput goal – -XX:GCTimeRatio, total time to be spent on GC
Maximum Pause Time Goal – -XX:MaxGCPauseMillis, indication for collector for pause time
-XX:ParallelGCThreads – number of CPU
What are Advance GC Tuning?
-Xms – starting heap size
Xmx – maximum heap size
-XX:MinHeapFreeRatio – 40 – proportion of free space to expand
-XX:MaxHeapFreeRatio – 70 – proportion of free space to shrink
-XX:NewSize – intial size of new young generation [eden + survivor 1 + survivor 2]
-XX:MaxNewSize – maximum young size
-XX:NewRatio – ratio between young and tenured size[old]
-XX:SurvivorRatio – ratio between each survivor and eden
-XX:TargetSurvivorRatio – ratio between each survivor and eden after GC
-XX:Permsize – starting permanent generation
-XX:MaxPermSize – max size of permanent generation
-XX:+DisableExplicitGC – disable System.gc()
-XX:+ScavengeBeforeFullGC – perform minor before major collection
-XX:+UseGCOverheadLimit – if 98% of CPU time is spent on GC, then throws OutOfMemoryError