Hotspot JVM Options in Java

Hotspot JVM Options in Java

Hotspot JVM (Java Virtual Machine) Options in Java is a core component of the Java SE platform. It holds the JVM specification and used as a shared library in the Java Run-time Environment (JRE). These Hotspot JVM options are used as a core parameters for the JVM to run our application or programs. 
Java developers has used N no. of JVM parameters or JVM Options inside JDK to handle to application process. Since its used or changed very rarely by developers and also its hard to remember all the JVM options. We have heard about Java Heap Size, printing Garbage Collection details etc., in Java. In most of application we will be worried about using Garbage Collection and to maintain memory very efficiently. Next about how to do performance tuning in Java. Apart from these 2 there are lot of JVM options. All these options can be changed in JVM options command from its default values. 
Lets see few JVM Options and how to change those values according to our application need from its default value. For more detail on Hotspot JVM Options you can refer to official site link

Using "java -help" we can get the list of help options where "-X print help on non-standard options". -X are non-standard and subject to change without notice in subsequent releases of the JDK. -XX are not stable and are not recommended since these options are subject to change without notice.

java -X


    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by :>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by :>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by :>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni       perform additional checks for JNI functions
    -Xshare:off       do not attempt to use shared class data
    -Xshare:auto      use shared class data if possible (default)
    -Xshare:on        require using shared class data, otherwise fail.

Numeric Hotspot JVM Options can be by -XX:=. Numbers can include 'm' or 'M' for megabytes, 'k' or 'K' for kilobytes, and 'g' or 'G' for gigabytes (for example, " java -Xmx10m " will set maximum Java heap size with 10 megabytes which is 10240 kilobytes).

Boolean Hotspot JVM options can be turned on by -XX:+ and can be turned off by -XX:-. Here "+" for true and "-" for false.


java -XX:+PrintGCDetails


Heap
 def new generation   total 19008K, used 681K [0x00000000b7a00000, 0x00000000b8ea0000, 0x00000000cc4a0000)
  eden space 16896K,   4% used [0x00000000b7a00000, 0x00000000b7aaa6a8, 0x00000000b8a80000)
  from space 2112K,   0% used [0x00000000b8a80000, 0x00000000b8a80000, 0x00000000b8c90000)
  to   space 2112K,   0% used [0x00000000b8c90000, 0x00000000b8c90000, 0x00000000b8ea0000)
 tenured generation   total 42304K, used 0K [0x00000000cc4a0000, 0x00000000cedf0000, 0x00000000f5a00000)
   the space 42304K,   0% used [0x00000000cc4a0000, 0x00000000cc4a0000, 0x00000000cc4a0200, 0x00000000cedf0000)
 compacting perm gen  total 21248K, used 3244K [0x00000000f5a00000, 0x00000000f6ec0000, 0x0000000100000000)
   the space 21248K,  15% used [0x00000000f5a00000, 0x00000000f5d2b318, 0x00000000f5d2b400, 0x00000000f6ec0000)
No shared spaces configured.

String Hotspot JVM options can be set using -XX:=, specify file, path, or a list of commands.


Below are the list of Hotspot JVM Options


[Global flags]
uintx AdaptivePermSizeWeight               = 20               {product}
uintx AdaptiveSizeDecrementScaleFactor     = 4                {product}
uintx AdaptiveSizeMajorGCDecayTimeScale    = 10               {product}
uintx AdaptiveSizePausePolicy              = 0                {product}
uintx AdaptiveSizePolicyCollectionCostMargin  = 50               {product}
uintx AdaptiveSizePolicyInitializingSteps  = 20               {product}
uintx AdaptiveSizePolicyOutputInterval     = 0                {product}
uintx AdaptiveSizePolicyWeight             = 10               {product}
uintx AdaptiveSizeThroughPutPolicy         = 0                {product}
uintx AdaptiveTimeWeight                   = 25               {product}
 bool AdjustConcurrency                    = false            {product}
 bool AggressiveOpts                       = false            {product}
 intx AliasLevel                           = 3                {product}
 intx AllocatePrefetchDistance             = 256              {product}
 intx AllocatePrefetchInstr                = 0                {product}
 intx AllocatePrefetchLines                = 3                {product}
 intx AllocatePrefetchStepSize             = 64               {product}
 intx AllocatePrefetchStyle                = 1                {product}
 bool AllowJNIEnvProxy                     = false            {product}
 bool AllowParallelDefineClass             = false            {product}
 bool AllowUserSignalHandlers              = false            {product}
 bool AlwaysActAsServerClassMachine        = false            {product}
 bool AlwaysCompileLoopMethods             = false            {product}
 intx AlwaysInflate                        = 0                {product}
 bool AlwaysLockClassLoader                = false            {product}
 bool AlwaysPreTouch                       = false            {product}
 bool AlwaysRestoreFPU                     = false            {product}
 bool AlwaysTenure                         = false            {product}
 bool AnonymousClasses                     = false            {product}
 bool AssertOnSuspendWaitFailure           = false            {product}
 intx Atomics                              = 0                {product}
 intx AutoBoxCacheMax                      = 128              {C2 product}
uintx AutoGCSelectPauseMillis              = 5000             {product}
 intx BCEATraceLevel                       = 0                {product}
 intx BackEdgeThreshold                    = 100000           {pd product}
 bool BackgroundCompilation                = true             {pd product}
uintx BaseFootPrintEstimate                = 268435456        {product}
 intx BiasedLockingBulkRebiasThreshold     = 20               {product}
 intx BiasedLockingBulkRevokeThreshold     = 40               {product}
 intx BiasedLockingDecayTime               = 25000            {product}
 intx BiasedLockingStartupDelay            = 4000             {product}
 bool BindGCTaskThreadsToCPUs              = false            {product}
 bool BlockLayoutByFrequency               = true             {C2 product}
 intx BlockLayoutMinDiamondPercentage      = 20               {C2 product}
 bool BlockLayoutRotateLoops               = true             {C2 product}
 bool BlockOffsetArrayUseUnallocatedBlock  = false            {product}
 bool BranchOnRegister                     = false            {C2 product}
 bool BytecodeVerificationLocal            = false            {product}
 bool BytecodeVerificationRemote           = true             {product}
 intx CICompilerCount                      = 2                {product}
 bool CICompilerCountPerCPU                = false            {product}
 bool CITime                               = false            {product}
 bool CMSAbortSemantics                    = false            {product}
uintx CMSAbortablePrecleanMinWorkPerIteration  = 100              {product}
 intx CMSAbortablePrecleanWaitMillis       = 100              {product}
uintx CMSBitMapYieldQuantum                = 10485760         {product}
uintx CMSBootstrapOccupancy                = 50               {product}
 bool CMSClassUnloadingEnabled             = false            {product}
uintx CMSClassUnloadingMaxInterval         = 0                {product}
 bool CMSCleanOnEnter                      = true             {product}
 bool CMSCompactWhenClearAllSoftRefs       = true             {product}
uintx CMSConcMarkMultiple                  = 32               {product}
 bool CMSConcurrentMTEnabled               = true             {product}
uintx CMSCoordinatorYieldSleepCount        = 10               {product}
 bool CMSDumpAtPromotionFailure            = false            {product}
uintx CMSExpAvgFactor                      = 50               {product}
 bool CMSExtrapolateSweep                  = false            {product}
uintx CMSFullGCsBeforeCompaction           = 0                {product}
uintx CMSIncrementalDutyCycle              = 10               {product}
uintx CMSIncrementalDutyCycleMin           = 0                {product}
 bool CMSIncrementalMode                   = false            {product}
uintx CMSIncrementalOffset                 = 0                {product}
 bool CMSIncrementalPacing                 = true             {product}
uintx CMSIncrementalSafetyFactor           = 10               {product}
uintx CMSIndexedFreeListReplenish          = 4                {product}
 intx CMSInitiatingOccupancyFraction       = -1               {product}
 intx CMSInitiatingPermOccupancyFraction   = -1               {product}
 intx CMSIsTooFullPercentage               = 98               {product}
double CMSLargeCoalSurplusPercent           =  {product}
double CMSLargeSplitSurplusPercent          =  {product}
 bool CMSLoopWarn                          = false            {product}
uintx CMSMaxAbortablePrecleanLoops         = 0                {product}
 intx CMSMaxAbortablePrecleanTime          = 5000             {product}
uintx CMSOldPLABMax                        = 1024             {product}
uintx CMSOldPLABMin                        = 16               {product}
uintx CMSOldPLABNumRefills                 = 4                {product}
uintx CMSOldPLABReactivityCeiling          = 10               {product}
uintx CMSOldPLABReactivityFactor           = 2                {product}
 bool CMSOldPLABResizeQuicker              = false            {product}
uintx CMSOldPLABToleranceFactor            = 4                {product}
 bool CMSPLABRecordAlways                  = true             {product}
uintx CMSParPromoteBlocksToClaim           = 16               {product}
 bool CMSParallelRemarkEnabled             = true             {product}
 bool CMSParallelSurvivorRemarkEnabled     = true             {product}
 bool CMSPermGenPrecleaningEnabled         = true             {product}
uintx CMSPrecleanDenominator               = 3                {product}
uintx CMSPrecleanIter                      = 3                {product}
uintx CMSPrecleanNumerator                 = 2                {product}
 bool CMSPrecleanRefLists1                 = true             {product}
 bool CMSPrecleanRefLists2                 = false            {product}
 bool CMSPrecleanSurvivors1                = false            {product}
 bool CMSPrecleanSurvivors2                = true             {product}
uintx CMSPrecleanThreshold                 = 1000             {product}
 bool CMSPrecleaningEnabled                = true             {product}
 bool CMSPrintChunksInDump                 = false            {product}
 bool CMSPrintObjectsInDump                = false            {product}
uintx CMSRemarkVerifyVariant               = 1                {product}
 bool CMSReplenishIntermediate             = true             {product}
uintx CMSRescanMultiple                    = 32               {product}
uintx CMSRevisitStackSize                  = 1048576          {product}
uintx CMSSamplingGrain                     = 16384            {product}
 bool CMSScavengeBeforeRemark              = false            {product}
uintx CMSScheduleRemarkEdenPenetration     = 50               {product}
uintx CMSScheduleRemarkEdenSizeThreshold   = 2097152          {product}
uintx CMSScheduleRemarkSamplingRatio       = 5                {product}
double CMSSmallCoalSurplusPercent           =  {product}
double CMSSmallSplitSurplusPercent          =  {product}
 bool CMSSplitIndexedFreeListBlocks        = true             {product}
 intx CMSTriggerPermRatio                  = 80               {product}
 intx CMSTriggerRatio                      = 80               {product}
 bool CMSUseOldDefaults                    = false            {product}
 intx CMSWaitDuration                      = 2000             {product}
uintx CMSWorkQueueDrainThreshold           = 10               {product}
 bool CMSYield                             = true             {product}
uintx CMSYieldSleepCount                   = 0                {product}
 intx CMSYoungGenPerWorker                 = 16777216         {product}
uintx CMS_FLSPadding                       = 1                {product}
uintx CMS_FLSWeight                        = 75               {product}
uintx CMS_SweepPadding                     = 1                {product}
uintx CMS_SweepTimerThresholdMillis        = 10               {product}
uintx CMS_SweepWeight                      = 75               {product}
 bool CheckJNICalls                        = false            {product}
 bool ClassUnloading                       = true             {product}
 intx ClearFPUAtPark                       = 0                {product}
 bool ClipInlining                         = true             {product}
uintx CodeCacheExpansionSize               = 65536            {pd product}
uintx CodeCacheFlushingMinimumFreeSpace    = 1536000          {product}
uintx CodeCacheMinimumFreeSpace            = 512000           {product}
 bool CollectGen0First                     = false            {product}
 bool CompactFields                        = true             {product}
 intx CompilationPolicyChoice              = 0                {product}
ccstrlist CompileCommand                       =                  {product}
ccstr CompileCommandFile                   =  {product}
ccstrlist CompileOnly                          =                  {product}
 intx CompileThreshold                     = 10000            {pd product}
 bool CompilerThreadHintNoPreempt          = true             {product}
 intx CompilerThreadPriority               = -1               {product}
 intx CompilerThreadStackSize              = 0                {pd product}
uintx ConcGCThreads                        = 0                {product}
 intx ConditionalMoveLimit                 = 3                {C2 pd product}
 bool ConvertSleepToYield                  = true             {pd product}
 bool ConvertYieldToSleep                  = false            {product}
 bool DTraceAllocProbes                    = false            {product}
 bool DTraceMethodProbes                   = false            {product}
 bool DTraceMonitorProbes                  = false            {product}
uintx DefaultMaxRAMFraction                = 4                {product}
 intx DefaultThreadPriority                = -1               {product}
 intx DeferPollingPageLoopCount            = -1               {product}
 intx DeferThrSuspendLoopCount             = 4000             {product}
 bool DeoptimizeRandom                     = false            {product}
 bool DisableAttachMechanism               = false            {product}
 bool DisableExplicitGC                    = false            {product}
 bool DisplayVMOutputToStderr              = false            {product}
 bool DisplayVMOutputToStdout              = false            {product}
 bool DoEscapeAnalysis                     = true             {C2 product}
 intx DominatorSearchLimit                 = 1000             {C2 diagnostic}
 bool DontCompileHugeMethods               = true             {product}
 bool DontYieldALot                        = false            {pd product}
 bool DumpSharedSpaces                     = false            {product}
 bool EagerXrunInit                        = false            {product}
 intx EliminateAllocationArraySizeLimit    = 64               {C2 product}
 bool EliminateAllocations                 = true             {C2 product}
 bool EliminateAutoBox                     = false            {C2 diagnostic}
 bool EliminateLocks                       = true             {C2 product}
 intx EmitSync                             = 0                {product}
uintx ErgoHeapSizeLimit                    = 0                {product}
ccstr ErrorFile                            =  {product}
 bool EstimateArgEscape                    = true             {product}
 intx EventLogLength                       = 2000             {product}
 bool ExplicitGCInvokesConcurrent          = false            {product}
 bool ExplicitGCInvokesConcurrentAndUnloadsClasses  = false            {product}
 bool ExtendedDTraceProbes                 = false            {product}
 bool FLSAlwaysCoalesceLarge               = false            {product}
uintx FLSCoalescePolicy                    = 2                {product}
double FLSLargestBlockCoalesceProximity     =  {product}
 bool FailOverToOldVerifier                = true             {product}
 bool FastTLABRefill                       = true             {product}
 intx FenceInstruction                     = 0                {product}
 intx FieldsAllocationStyle                = 1                {product}
 bool FilterSpuriousWakeups                = true             {product}
 bool ForceFullGCJVMTIEpilogues            = false            {product}
 bool ForceNUMA                            = false            {product}
 bool ForceSharedSpaces                    = false            {product}
 bool ForceTimeHighResolution              = false            {product}
 intx FreqInlineSize                       = 325              {pd product}
 intx G1ConcRefinementGreenZone            = 0                {product}
 intx G1ConcRefinementRedZone              = 0                {product}
 intx G1ConcRefinementServiceIntervalMillis  = 300              {product}
uintx G1ConcRefinementThreads              = 0                {product}
 intx G1ConcRefinementThresholdStep        = 0                {product}
 intx G1ConcRefinementYellowZone           = 0                {product}
 intx G1ConfidencePercent                  = 50               {product}
uintx G1HeapRegionSize                     = 0                {product}
 intx G1MarkRegionStackSize                = 1048576          {product}
 intx G1RSetRegionEntries                  = 0                {product}
uintx G1RSetScanBlockSize                  = 64               {product}
 intx G1RSetSparseRegionEntries            = 0                {product}
 intx G1RSetUpdatingPauseTimePercent       = 10               {product}
 intx G1ReservePercent                     = 10               {product}
 intx G1SATBBufferSize                     = 1024             {product}
 intx G1UpdateBufferSize                   = 256              {product}
 bool G1UseAdaptiveConcRefinement          = true             {product}
uintx GCDrainStackTargetSize               = 64               {product}
uintx GCHeapFreeLimit                      = 2                {product}
 bool GCLockerInvokesConcurrent            = false            {product}
 bool GCOverheadReporting                  = false            {product}
 intx GCOverheadReportingPeriodMS          = 100              {product}
uintx GCPauseIntervalMillis                = 0                {product}
uintx GCTaskTimeStampEntries               = 200              {product}
uintx GCTimeLimit                          = 98               {product}
uintx GCTimeRatio                          = 99               {product}
ccstr HPILibPath                           =  {product}
 bool HandlePromotionFailure               = true             {product}
uintx HeapBaseMinAddress                   = 2147483648       {pd product}
 bool HeapDumpAfterFullGC                  = false            {manageable}
 bool HeapDumpBeforeFullGC                 = false            {manageable}
 bool HeapDumpOnOutOfMemoryError           = false            {manageable}
ccstr HeapDumpPath                         =  {manageable}
uintx HeapFirstMaximumCompactionCount      = 3                {product}
uintx HeapMaximumCompactionInterval        = 20               {product}
 bool IgnoreUnrecognizedVMOptions          = false            {product}
uintx InitialCodeCacheSize                 = 2555904          {pd product}
uintx InitialHeapSize                     := 64932608         {product}
uintx InitialRAMFraction                   = 64               {product}
uintx InitialSurvivorRatio                 = 8                {product}
 intx InitialTenuringThreshold             = 7                {product}
uintx InitiatingHeapOccupancyPercent       = 45               {product}
 bool Inline                               = true             {product}
 intx InlineSmallCode                      = 1000             {pd product}
 bool InsertMemBarAfterArraycopy           = true             {C2 product}
 intx InteriorEntryAlignment               = 16               {C2 pd product}
 intx InterpreterProfilePercentage         = 33               {product}
 bool JNIDetachReleasesMonitors            = true             {product}
 bool JavaMonitorsInStackTrace             = true             {product}
 intx JavaPriority10_To_OSPriority         = -1               {product}
 intx JavaPriority1_To_OSPriority          = -1               {product}
 intx JavaPriority2_To_OSPriority          = -1               {product}
 intx JavaPriority3_To_OSPriority          = -1               {product}
 intx JavaPriority4_To_OSPriority          = -1               {product}
 intx JavaPriority5_To_OSPriority          = -1               {product}
 intx JavaPriority6_To_OSPriority          = -1               {product}
 intx JavaPriority7_To_OSPriority          = -1               {product}
 intx JavaPriority8_To_OSPriority          = -1               {product}
 intx JavaPriority9_To_OSPriority          = -1               {product}
uintx LargePageHeapSizeThreshold           = 134217728        {product}
uintx LargePageSizeInBytes                 = 0                {product}
 bool LazyBootClassLoader                  = true             {product}
 intx LoopOptsCount                        = 43               {C2 product}
 intx LoopUnrollLimit                      = 60               {C2 pd product}
 intx LoopUnrollMin                        = 4                {C2 product}
 bool LoopUnswitching                      = true             {C2 product}
 bool ManagementServer                     = false            {product}
uintx MarkStackSize                        = 4194304          {product}
uintx MarkStackSizeMax                     = 536870912        {product}
 intx MarkSweepAlwaysCompactCount          = 4                {product}
uintx MarkSweepDeadRatio                   = 5                {product}
 intx MaxBCEAEstimateLevel                 = 5                {product}
 intx MaxBCEAEstimateSize                  = 150              {product}
 intx MaxDirectMemorySize                  = -1               {product}
 bool MaxFDLimit                           = true             {product}
uintx MaxGCMinorPauseMillis                = 18446744073709551615 {product}
uintx MaxGCPauseMillis                     = 18446744073709551615 {product}
uintx MaxHeapFreeRatio                     = 70               {product}
uintx MaxHeapSize                         := 1040187392       {product}
 intx MaxInlineLevel                       = 9                {product}
 intx MaxInlineSize                        = 35               {product}
 intx MaxJavaStackTraceDepth               = 1024             {product}
 intx MaxJumpTableSize                     = 65000            {C2 product}
 intx MaxJumpTableSparseness               = 5                {C2 product}
 intx MaxLabelRootDepth                    = 1100             {C2 product}
uintx MaxLiveObjectEvacuationRatio         = 100              {product}
 intx MaxLoopPad                           = 11               {C2 product}
uintx MaxNewSize                           = 18446744073709486080 {product}
 intx MaxNodeLimit                         = 65000            {C2 product}
uintx MaxPermHeapExpansion                 = 5439488          {product}
uintx MaxPermSize                          = 174063616        {pd product}
uint64_t MaxRAM                               = 137438953472     {pd product}
uintx MaxRAMFraction                       = 4                {product}
 intx MaxRecursiveInlineLevel              = 1                {product}
 intx MaxTenuringThreshold                 = 15               {product}
 intx MaxTrivialSize                       = 6                {product}
 bool MethodFlushing                       = true             {product}
 intx MinCodeCacheFlushingInterval         = 30               {product}
uintx MinHeapDeltaBytes                    = 196608           {product}
uintx MinHeapFreeRatio                     = 40               {product}
 intx MinInliningThreshold                 = 250              {product}
 intx MinJumpTableSize                     = 18               {C2 product}
uintx MinPermHeapExpansion                 = 327680           {product}
uintx MinRAMFraction                       = 2                {product}
uintx MinSurvivorRatio                     = 3                {product}
uintx MinTLABSize                          = 2048             {product}
 intx MonitorBound                         = 0                {product}
 bool MonitorInUseLists                    = false            {product}
 intx MultiArrayExpandLimit                = 6                {C2 product}
 bool MustCallLoadClassInternal            = false            {product}
 intx NUMAChunkResizeWeight                = 20               {product}
 intx NUMAPageScanRate                     = 256              {product}
 intx NUMASpaceResizeRate                  = 1073741824       {product}
 bool NUMAStats                            = false            {product}
 intx NativeMonitorFlags                   = 0                {product}
 intx NativeMonitorSpinLimit               = 20               {product}
 intx NativeMonitorTimeout                 = -1               {product}
 bool NeedsDeoptSuspend                    = false            {pd product}
 bool NeverActAsServerClassMachine         = false            {pd product}
 bool NeverTenure                          = false            {product}
 intx NewRatio                             = 2                {product}
uintx NewSize                              = 1310720          {product}
uintx NewSizeThreadIncrease                = 5320             {pd product}
 intx NmethodSweepCheckInterval            = 5                {product}
 intx NmethodSweepFraction                 = 4                {product}
 intx NodeLimitFudgeFactor                 = 1000             {C2 product}
 intx NumberOfLoopInstrToAlign             = 4                {C2 product}
 intx ObjectAlignmentInBytes               = 8                {lp64_product}
uintx OldPLABSize                          = 1024             {product}
uintx OldPLABWeight                        = 50               {product}
uintx OldSize                              = 5439488          {product}
 bool OmitStackTraceInFastThrow            = true             {product}
ccstrlist OnError                              =                  {product}
ccstrlist OnOutOfMemoryError                   =                  {product}
 intx OnStackReplacePercentage             = 140              {pd product}
 bool OptimizeFill                         = false            {C2 product}
 bool OptimizeStringConcat                 = false            {C2 product}
 bool OptoBundling                         = false            {C2 pd product}
 intx OptoLoopAlignment                    = 16               {pd product}
 bool OptoScheduling                       = false            {C2 pd product}
uintx PLABWeight                           = 75               {product}
 bool PSChunkLargeArrays                   = true             {product}
 intx ParGCArrayScanChunk                  = 50               {product}
uintx ParGCDesiredObjsFromOverflowList     = 20               {product}
 bool ParGCTrimOverflow                    = true             {product}
 bool ParGCUseLocalOverflow                = false            {product}
 intx ParallelGCBufferWastePct             = 10               {product}
 bool ParallelGCRetainPLAB                 = true             {product}
uintx ParallelGCThreads                    = 0                {product}
 bool ParallelGCVerbose                    = false            {product}
uintx ParallelOldDeadWoodLimiterMean       = 50               {product}
uintx ParallelOldDeadWoodLimiterStdDev     = 80               {product}
 bool ParallelRefProcBalancingEnabled      = true             {product}
 bool ParallelRefProcEnabled               = false            {product}
 bool PartialPeelAtUnsignedTests           = true             {C2 product}
 bool PartialPeelLoop                      = true             {C2 product}
 intx PartialPeelNewPhiDelta               = 0                {C2 product}
uintx PausePadding                         = 1                {product}
 intx PerBytecodeRecompilationCutoff       = 200              {product}
 intx PerBytecodeTrapLimit                 = 4                {product}
 intx PerMethodRecompilationCutoff         = 400              {product}
 intx PerMethodTrapLimit                   = 100              {product}
 bool PerfAllowAtExitRegistration          = false            {product}
 bool PerfBypassFileSystemCheck            = false            {product}
 intx PerfDataMemorySize                   = 32768            {product}
 intx PerfDataSamplingInterval             = 50               {product}
ccstr PerfDataSaveFile                     =  {product}
 bool PerfDataSaveToFile                   = false            {product}
 bool PerfDisableSharedMem                 = false            {product}
 intx PerfMaxStringConstLength             = 1024             {product}
uintx PermGenPadding                       = 3                {product}
uintx PermMarkSweepDeadRatio               = 20               {product}
uintx PermSize                             = 21757952         {pd product}
 bool PostSpinYield                        = true             {product}
 intx PreBlockSpin                         = 10               {product}
 intx PreInflateSpin                       = 10               {pd product}
 bool PreSpinYield                         = false            {product}
 bool PreferInterpreterNativeStubs         = false            {pd product}
 intx PrefetchCopyIntervalInBytes          = 576              {product}
 intx PrefetchFieldsAhead                  = 1                {product}
 intx PrefetchScanIntervalInBytes          = 576              {product}
 bool PreserveAllAnnotations               = false            {product}
uintx PreserveMarkStackSize                = 1024             {product}
uintx PretenureSizeThreshold               = 0                {product}
 bool PrintAdaptiveSizePolicy              = false            {product}
 bool PrintCMSInitiationStatistics         = false            {product}
 intx PrintCMSStatistics                   = 0                {product}
 bool PrintClassHistogram                  = false            {manageable}
 bool PrintClassHistogramAfterFullGC       = false            {manageable}
 bool PrintClassHistogramBeforeFullGC      = false            {manageable}
 bool PrintCommandLineFlags                = false            {product}
 bool PrintCompilation                     = false            {product}
 bool PrintConcurrentLocks                 = false            {manageable}
 intx PrintFLSCensus                       = 0                {product}
 intx PrintFLSStatistics                   = 0                {product}
 bool PrintFlagsFinal                     := true             {product}
 bool PrintFlagsInitial                    = false            {product}
 bool PrintGC                              = false            {manageable}
 bool PrintGCApplicationConcurrentTime     = false            {product}
 bool PrintGCApplicationStoppedTime        = false            {product}
 bool PrintGCDateStamps                    = false            {manageable}
 bool PrintGCDetails                       = false            {manageable}
 bool PrintGCTaskTimeStamps                = false            {product}
 bool PrintGCTimeStamps                    = false            {manageable}
 bool PrintHeapAtGC                        = false            {product rw}
 bool PrintHeapAtGCExtended                = false            {product rw}
 bool PrintHeapAtSIGBREAK                  = true             {product}
 bool PrintJNIGCStalls                     = false            {product}
 bool PrintJNIResolving                    = false            {product}
 bool PrintOldPLAB                         = false            {product}
 bool PrintOopAddress                      = false            {product}
 bool PrintPLAB                            = false            {product}
 bool PrintParallelOldGCPhaseTimes         = false            {product}
 bool PrintPreciseBiasedLockingStatistics  = false            {C2 diagnostic}
 bool PrintPromotionFailure                = false            {product}
 bool PrintReferenceGC                     = false            {product}
 bool PrintRevisitStats                    = false            {product}
 bool PrintSafepointStatistics             = false            {product}
 intx PrintSafepointStatisticsCount        = 300              {product}
 intx PrintSafepointStatisticsTimeout      = -1               {product}
 bool PrintSharedSpaces                    = false            {product}
 bool PrintTLAB                            = false            {product}
 bool PrintTenuringDistribution            = false            {product}
 bool PrintVMOptions                       = false            {product}
 bool PrintVMQWaitTime                     = false            {product}
uintx ProcessDistributionStride            = 4                {product}
 bool ProfileInterpreter                   = true             {pd product}
 bool ProfileIntervals                     = false            {product}
 intx ProfileIntervalsTicks                = 100              {product}
 intx ProfileMaturityPercentage            = 20               {product}
 bool ProfileVM                            = false            {product}
 bool ProfilerPrintByteCodeStatistics      = false            {product}
 bool ProfilerRecordPC                     = false            {product}
uintx PromotedPadding                      = 3                {product}
 intx QueuedAllocationWarningCount         = 0                {product}
 bool RangeCheckElimination                = true             {product}
 intx ReadPrefetchInstr                    = 0                {product}
 intx ReadSpinIterations                   = 100              {product}
 bool ReassociateInvariants                = true             {C2 product}
 bool ReduceBulkZeroing                    = true             {C2 product}
 bool ReduceFieldZeroing                   = true             {C2 product}
 bool ReduceInitialCardMarks               = true             {C2 product}
 bool ReduceSignalUsage                    = false            {product}
 intx RefDiscoveryPolicy                   = 0                {product}
 bool ReflectionWrapResolutionErrors       = true             {product}
 bool RegisterFinalizersAtInit             = true             {product}
 bool RelaxAccessControlCheck              = false            {product}
 bool RequireSharedSpaces                  = false            {product}
uintx ReservedCodeCacheSize                = 50331648         {pd product}
 bool ResizeOldPLAB                        = true             {product}
 bool ResizePLAB                           = true             {product}
 bool ResizeTLAB                           = true             {pd product}
 bool RestoreMXCSROnJNICalls               = false            {product}
 bool RewriteBytecodes                     = false            {pd product}
 bool RewriteFrequentPairs                 = false            {pd product}
 intx SafepointSpinBeforeYield             = 2000             {product}
 bool SafepointTimeout                     = false            {product}
 intx SafepointTimeoutDelay                = 10000            {product}
 bool ScavengeBeforeFullGC                 = true             {product}
 intx SelfDestructTimer                    = 0                {product}
uintx SharedDummyBlockSize                 = 536870912        {product}
uintx SharedMiscCodeSize                   = 4194304          {product}
uintx SharedMiscDataSize                   = 4194304          {product}
uintx SharedReadOnlySize                   = 10485760         {product}
uintx SharedReadWriteSize                  = 12582912         {product}
 bool ShowMessageBoxOnError                = false            {product}
 intx SoftRefLRUPolicyMSPerMB              = 1000             {product}
 bool SplitIfBlocks                        = true             {product}
 intx StackRedPages                        = 1                {pd product}
 intx StackShadowPages                     = 6                {pd product}
 bool StackTraceInThrowable                = true             {product}
 intx StackYellowPages                     = 2                {pd product}
 bool StartAttachListener                  = false            {product}
 intx StarvationMonitorInterval            = 200              {product}
 bool StressLdcRewrite                     = false            {product}
 bool StressTieredRuntime                  = false            {product}
 bool SuppressFatalErrorMessage            = false            {product}
uintx SurvivorPadding                      = 3                {product}
 intx SurvivorRatio                       := 6                {product}
 intx SuspendRetryCount                    = 50               {product}
 intx SuspendRetryDelay                    = 5                {product}
 intx SyncFlags                            = 0                {product}
ccstr SyncKnobs                            =  {product}
 intx SyncVerbose                          = 0                {product}
uintx TLABAllocationWeight                 = 35               {product}
uintx TLABRefillWasteFraction              = 64               {product}
uintx TLABSize                             = 0                {product}
 bool TLABStats                            = true             {product}
uintx TLABWasteIncrement                   = 4                {product}
uintx TLABWasteTargetPercent               = 1                {product}
 intx TargetPLABWastePct                   = 10               {product}
 intx TargetSurvivorRatio                  = 50               {product}
uintx TenuredGenerationSizeIncrement       = 20               {product}
uintx TenuredGenerationSizeSupplement      = 80               {product}
uintx TenuredGenerationSizeSupplementDecay  = 2                {product}
 intx ThreadPriorityPolicy                 = 0                {product}
 bool ThreadPriorityVerbose                = false            {product}
uintx ThreadSafetyMargin                   = 52428800         {product}
 intx ThreadStackSize                      = 1024             {pd product}
uintx ThresholdTolerance                   = 10               {product}
 intx Tier1BytecodeLimit                   = 10               {product}
 intx Tier1FreqInlineSize                  = 35               {C2 product}
 intx Tier1Inline                          = 0                {C2 product}
 intx Tier1LoopOptsCount                   = 0                {C2 product}
 intx Tier1MaxInlineSize                   = 8                {C2 product}
 bool Tier1UpdateMethodData                = false            {product}
 intx Tier2BackEdgeThreshold               = 100000           {pd product}
 intx Tier2CompileThreshold                = 10000            {pd product}
 intx Tier3BackEdgeThreshold               = 100000           {pd product}
 intx Tier3CompileThreshold                = 20000            {pd product}
 intx Tier4BackEdgeThreshold               = 100000           {pd product}
 intx Tier4CompileThreshold                = 40000            {pd product}
 bool TieredCompilation                    = false            {pd product}
 bool TraceBiasedLocking                   = false            {product}
 bool TraceClassLoading                    = false            {product rw}
 bool TraceClassLoadingPreorder            = false            {product}
 bool TraceClassResolution                 = false            {product}
 bool TraceClassUnloading                  = false            {product rw}
 bool TraceGen0Time                        = false            {product}
 bool TraceGen1Time                        = false            {product}
ccstr TraceJVMTI                           =  {product}
 bool TraceLoaderConstraints               = false            {product rw}
 bool TraceMonitorInflation                = false            {product}
 bool TraceParallelOldGCTasks              = false            {product}
 intx TraceRedefineClasses                 = 0                {product}
 bool TraceSafepointCleanupTime            = false            {product}
 bool TraceSuperWord                       = false            {C2 product}
 bool TraceSuspendWaitFailures             = false            {product}
 intx TrackedInitializationLimit           = 50               {C2 product}
 intx TypeProfileMajorReceiverPercent      = 90               {product}
 intx TypeProfileWidth                     = 2                {product}
 intx UnguardOnExecutionViolation          = 0                {product}
 bool Use486InstrsOnly                     = false            {product}
 bool UseAdaptiveGCBoundary                = false            {product}
 bool UseAdaptiveGenerationSizePolicyAtMajorCollection  = true             {product}
 bool UseAdaptiveGenerationSizePolicyAtMinorCollection  = true             {product}
 bool UseAdaptiveNUMAChunkSizing           = true             {product}
 bool UseAdaptiveSizeDecayMajorGCCost      = true             {product}
 bool UseAdaptiveSizePolicy                = true             {product}
 bool UseAdaptiveSizePolicyFootprintGoal   = true             {product}
 bool UseAdaptiveSizePolicyWithSystemGC    = false            {product}
 bool UseAddressNop                        = true             {product}
 bool UseAltSigs                           = false            {product}
 bool UseAutoGCSelectPolicy                = false            {product}
 bool UseBiasedLocking                     = true             {product}
 bool UseBimorphicInlining                 = true             {C2 product}
 bool UseBoundThreads                      = true             {product}
 bool UseCMSBestFit                        = true             {product}
 bool UseCMSCollectionPassing              = true             {product}
 bool UseCMSCompactAtFullCollection        = true             {product}
 bool UseCMSInitiatingOccupancyOnly        = false            {product}
 bool UseCodeCacheFlushing                 = false            {product}
 bool UseCompiler                          = true             {product}
 bool UseCompilerSafepoints                = true             {product}
 bool UseCompressedOops                   := true             {lp64_product}
 bool UseConcMarkSweepGC                   = false            {product}
 bool UseCountLeadingZerosInstruction      = false            {product}
 bool UseCounterDecay                      = true             {product}
 bool UseDivMod                            = true             {C2 product}
 bool UseFPUForSpilling                    = false            {C2 product}
 bool UseFastAccessorMethods               = true             {product}
 bool UseFastEmptyMethods                  = true             {product}
 bool UseFastJNIAccessors                  = true             {product}
 bool UseG1GC                              = false            {product}
 bool UseGCOverheadLimit                   = true             {product}
 bool UseGCTaskAffinity                    = false            {product}
 bool UseHeavyMonitors                     = false            {product}
 bool UseInlineCaches                      = true             {product}
 bool UseInterpreter                       = true             {product}
 bool UseJumpTables                        = true             {C2 product}
 bool UseLWPSynchronization                = true             {product}
 bool UseLargePages                        = false            {pd product}
 bool UseLargePagesIndividualAllocation    = false            {pd product}
 bool UseLinuxPosixThreadCPUClocks         = false            {product}
 bool UseLoopCounter                       = true             {product}
 bool UseLoopPredicate                     = true             {C2 product}
 bool UseMaximumCompactionOnSystemGC       = true             {product}
 bool UseMembar                            = false            {product}
 bool UseNUMA                              = false            {product}
 bool UseNewLongLShift                     = false            {product}
 bool UseNiagaraInstrs                     = false            {product}
 bool UseOSErrorReporting                  = false            {pd product}
 bool UseOldInlining                       = true             {C2 product}
 bool UseOnStackReplacement                = true             {pd product}
 bool UseOnlyInlinedBimorphic              = true             {C2 product}
 bool UseOprofile                          = false            {product}
 bool UseOptoBiasInlining                  = true             {C2 product}
 bool UsePSAdaptiveSurvivorSizePolicy      = true             {product}
 bool UseParNewGC                          = false            {product}
 bool UseParallelDensePrefixUpdate         = true             {product}
 bool UseParallelGC                        = false            {product}
 bool UseParallelOldGC                     = false            {product}
 bool UseParallelOldGCCompacting           = true             {product}
 bool UseParallelOldGCDensePrefix          = true             {product}
 bool UsePerfData                          = true             {product}
 bool UsePopCountInstruction               = true             {product}
 intx UseSSE                               = 4                {product}
 bool UseSSE42Intrinsics                   = true             {product}
 bool UseSerialGC                          = false            {product}
 bool UseSharedSpaces                      = false            {product}
 bool UseSignalChaining                    = true             {product}
 bool UseSpinning                          = false            {product}
 bool UseSplitVerifier                     = true             {product}
 bool UseStoreImmI16                       = false            {product}
 bool UseStringCache                       = false            {product}
 bool UseSuperWord                         = true             {C2 product}
 bool UseTLAB                              = true             {pd product}
 bool UseThreadPriorities                  = true             {pd product}
 bool UseTypeProfile                       = true             {product}
 bool UseUnalignedLoadStores               = false            {product}
 bool UseVMInterruptibleIO                 = true             {product}
 bool UseVectoredExceptions                = false            {pd product}
 bool UseXMMForArrayCopy                   = true             {product}
 bool UseXmmI2D                            = false            {product}
 bool UseXmmI2F                            = false            {product}
 bool UseXmmLoadAndClearUpper              = true             {product}
 bool UseXmmRegToRegMoveAll                = true             {product}
 bool VMThreadHintNoPreempt                = false            {product}
 intx VMThreadPriority                     = -1               {product}
 intx VMThreadStackSize                    = 1024             {pd product}
 intx ValueSearchLimit                     = 1000             {C2 product}
 bool VerifyMergedCPBytecodes              = true             {product}
 intx WorkAroundNPTLTimedWaitHang          = 1                {product}
uintx YoungGenerationSizeIncrement         = 20               {product}
uintx YoungGenerationSizeSupplement        = 80               {product}
uintx YoungGenerationSizeSupplementDecay   = 8                {product}
uintx YoungPLABSize                        = 4096             {product}
 bool ZeroTLAB                             = false            {product}
 intx hashCode                             = 0                {product}


PriorityBlockingQueue in Java

 
PriorityBlockingQueue in java

In our last tutorial we have see about PriorityQueue and how its used in Java with simple example. In this tutorial we will see about PriorityBlockingQueue and it works and also the difference between PriorityQueue and PriorityBlockingQueue. 
  • PriorityBlockingQueue uses same unbounded blocking queue that uses the same ordering rules as PriorityQueue and supplies blocking retrieval operations. 
  • PriorityBlockingQueue does not allow null values to be added.
  • PriorityBlockingQueue also uses natural sorting order and will not permit non-comparable objects to be insert which will result in ClassCastException exception.
  • PriorityBlockingQueue uses methods as same as PriorityQueue class except drainTo() and remainingCapacity() methods. 
  • drainTo(Collection<? super E> c) method used remove all available elements from the queue and adds them to the given collection.
  • drainTo(Collection<? super E> c, int maxElements) method used to remove at most the given number of available elements from the queue and adds them to the given collection.
  • remainingCapacity() method used to return Integer.MAX_VALUE because a PriorityBlockingQueue is not capacity constrained.
  • Method iterator() is not guaranteed to traverse the elements of PriorityBlockingQueue in any particular order. We can see this in below example. 

Difference Between PriorityBlockingQueue and PriorityQueue:
  • PriorityQueue is not thread safe, where as PriorityBlockingQueue is thread safe. 
  • PriorityBlockingQueue introduced in JDK 5 which added with concurrent package. 

Now lets see simple example for PriorityBlockingQueue and how its working under multi-threading.



import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.PriorityBlockingQueue;

public class PriorityBlockingQueueTest {
 
 PriorityBlockingQueue<String> priBlockQ = new PriorityBlockingQueue<String>();
 
 public PriorityBlockingQueueTest(){
  priBlockQ.add("300");
  priBlockQ.add("400");
  priBlockQ.add("100");
  priBlockQ.add("500");
  priBlockQ.add("200");  
 }
 
 public void performTask() {
  // traversing order not guaranteed
  System.out.println("\nQueue iterator() : ");
  Iterator<String> itr = priBlockQ.iterator();
  while (itr.hasNext()) {
   String string = (String) itr.next();
   System.out.print(string+", ");
  }
  
  System.out.println("\n\nList iterator() : ");
  List<String> list = new ArrayList<String>();
  priBlockQ.drainTo(list);
  itr = list.iterator();
  while (itr.hasNext()) {
   String string = (String) itr.next();
   System.out.print(string+", ");
  }
  
  System.out.println("\n\ncontains() : "+priBlockQ.contains("400"));
  System.out.println("\nremainingCapacity() : "+priBlockQ.remainingCapacity());
 }
 
 public static void main(String[] args) {
  new PriorityBlockingQueueTest().performTask();
 }
}


OUTPUT:


Queue iterator() : 
100, 200, 300, 500, 400, 

List iterator() : 
100, 200, 300, 400, 500, 

contains() : false

remainingCapacity() : 2147483647








PriorityQueue in Java

 
PriorityQueue in Java

PriorityQueue is unbounded priority queue based on priority heap. 
  • Basically PriorityQueue are ordered according to natural ordering or by a Comparator provided at queue construction time, depending on which constructor is used. 
  • Another important that PriorityQueue won't take null value as input. 
  • Since PriorityQueue reply on natural ordering it won't take non-comparable object as input which will throw ClassCastException
  • Internally memory size will be managed automatically as and when elements added to the PriorityQueue.
  • By using Iterator interface its not guaranteed to traverse the elements of the PriorityQueue in any particular order. For ordered traversal need to use Arrays.sort(pq.toArray()). 
  • By implementation PriorityQueue is not synchronized and non-thread safe. Suppose if we need synchronized/thread-safe Queue then we need to go for PriorityBlockingQueue class instead of PriorityQueue.

Lets see list of constructors and methods in PriorityQueue class.

Constructors:

PriorityQueue()
          Default constructor which orders the elements in natural ordering.

PriorityQueue(Collection<? extends E> c)
          PriorityQueue will be created containing the elements in the specified collection.
 
PriorityQueue(int initialCapacity)
 PriorityQueue will be created with the initial size specified and orders its elements according to their natural ordering.

PriorityQueue(int initialCapacity, Comparator<? super E> comparator)
 PriorityQueue will be created with the initial size specified and orders its elements according to the specified comparator

PriorityQueue(PriorityQueue<? extends E> c)
          PriorityQueue will be created with containing the elements in the specified priority queue.

PriorityQueue(SortedSet<? extends E> c)
          PriorityQueue will be created with containing the elements in the specified sorted set.


Methods:

boolean add(E e) 
Inserts the Element into PriorityQueue.

void clear()
Removes all elements from PriorityQueue.

Comparator<? super E> comparator()
Return Comparator used to order the elements in queue, or returns null if its ordered the queue in natural ordering. 

boolean contains(Object o) 
Return true if particular Object present in the queue else false.

Iterator<E> iterator() 
Used to iterate over the elements in the queue.

boolean offer(E e) 
Its same as add() method inserts the Elements into PriorityQueue.

Element peek()
Retrieves the Element from the head of queue else return null if queue is empty.

Element poll()
Retrieves and removes the Element from the head of queue else return null if queue is empty.

boolean remove() 
Retrieves and removes head of this queue.

boolean remove(Object o) 
Removes given Object from the queue if its present in the queue.

int size()
Returns the queue size. 

Object[] toArray()
Returns Object array containing all of the elements in this queue.

 <T> T[] toArray(T[] a)
Returns an array containing all of the elements in this queue; the run-time type of the returned array is that of the specified array and returned array elements are in no particular order.



Now lets see simple program using PriorityQueue class


import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Queue;

public class PriorityQueueTest {

 public static void main(String[] args) {
  
  Queue<String> pq = new PriorityQueue<String>();
  
  pq.add("java");
  pq.add("servlet");
  pq.add("hibernate");
  
  pq.offer(".net");
  pq.offer("c");
  pq.offer("Pascal");
  
  System.out.println("\nPriorityQueue size() : "+pq.size());
  
  System.out.println("\nPriorityQueue peek() : "+pq.peek());
  
  System.out.println("\nIerating Queue Elements : ");
  Iterator<String> itr = pq.iterator();
  while (itr.hasNext()) {
   String string = (String) itr.next();
   System.out.print(string+", ");
  }
  
  System.out.println("\n\nPriorityQueue poll() : "+pq.poll());
  
  System.out.println("\nPriorityQueue size() : "+pq.size());
  
  System.out.println("\nPriorityQueue remove() : "+pq.remove());
  
  System.out.println("\nPriorityQueue remove(\".net\") : "+pq.remove(".net"));
  
  System.out.println("\nPriorityQueue contains() : "+pq.contains("java"));
  
  System.out.println("\nPriorityQueue toArray() : ");
  Object[] array = pq.toArray();
  for (Object object : array) {
   System.out.print(object.toString()+", ");
  }
 }
}


OUTPUT:


PriorityQueue size() : 6

PriorityQueue peek() : .net

Ierating Queue Elements : 
.net, c, Pascal, servlet, hibernate, java, 

PriorityQueue poll() : .net

PriorityQueue size() : 5

PriorityQueue remove() : Pascal

PriorityQueue remove(".net") : false

PriorityQueue contains() : true

PriorityQueue toArray() : 
c, hibernate, java, servlet,