JAVA(1) JDK Commands JAVA(1) (NAME) java - ( ) (SYNOPSIS) : java [] mainclass [ ...] JAR: java [] -jar jarfile [ ...] : java [] -m module[/mainclass] [ ...] java [] --module module[/mainclass] [ ...] : java [] source-file [ ...] options : . (OVERVIEW OF JAVA OPTIONS) . mainclass . classname (main) . -jar jarfile JAR . jarfile JAR Main-Class:classname public static void main(String[] args) . -jar JAR (class path) . JAR jar . -m --module module[/mainclass] mainclass ( ) module . mainclass . (Standard Options for Java) . source-file . . (USING SOURCE-FILE MODE TO LAUNCH SINGLE-FILE SOURCE-CODE PROGRAMS) . args ... : mainclass source-file -jar jarfile -m --module module/mainclass . (DESCRIPTION) java . (JVM) main() . public static String . : public static void main(String[] args) java . (USING SOURCE-FILE MODE TO LAUNCH SINGLE-FILE SOURCE-CODE PROGRAMS) . : JDK_JAVA_OPTIONS java . JDK_JAVA_OPTIONS (USING THE JDK_JAVA_OPTIONS LAUNCHER ENVIRONMENT VARIABLE) . java (fully qualified) . -jar JAR (resources) . Main-Class . JAR main() . javaw : javaw java javaw . (Command Prompt) javaw . javaw (Dialog box) . (USING SOURCE-FILE MODE TO LAUNCH SINGLE-FILE SOURCE-CODE PROGRAMS) java . java : o . . o --source version . .java --source . . --source (version N) . (API) . --source N N JDK . : N . N . N Java SE (17) javac --source --release . .java --source java . --source <<>> . . . HelloWorld.java hello.World : java HelloWorld.java (unnamed package) . hello.World : javac -d HelloWorld.java java -cp hello.World : o . : --class-path --module-path --add-exports --add-modules --limit-modules --patch-module --upgrade-module-path . --enable-preview JEP 12 . o -processor -Werror . o (@-files) . @ . : o . o . o (Annotation processing) -proc:none . o --source --release . . o (unnamed module) . o (top-level) . o 7.6 (JLS) .java . o . : o . public static void main(String[]) . o . . o --add-modules=ALL-DEFAULT . --add-module . o . o . JEP 330: Launch Single-File Source-Code Programs . JDK_JAVA_OPTIONS (USING THE JDK_JAVA_OPTIONS LAUNCHER ENVIRONMENT VARIABLE) JDK_JAVA_OPTIONS . JDK_JAVA_OPTIONS ( isspace()) . java . java . JDK_JAVA_OPTIONS . (') (") . . . (@-files) . @-files (wildcard) . JDK_JAVA_OPTIONS ( -jar) java ( -h) . . JDK_JAVA_OPTIONS . : $ export JDK_JAVA_OPTIONS='-g @file1 -Dprop=value @file2 -Dws.prop="white spaces"' $ java -Xint @file3 : java -g @file1 -Dprop=value @file2 -Dws.prop="white spaces" -Xint @file3 (OVERVIEW OF JAVA OPTIONS) java : o (Standard Options for Java): (JVM) . JRE (verbose) . o (Extra Options for Java): Java HotSpot . JVM . -X . . Java HotSpot . (Performance Tuning Examples) . JVM . -XX . o (Advanced Runtime Options for Java): Java HotSpot VM . o JIT (Advanced JIT Compiler Options for java): (JIT) Java HotSpot VM . o (Advanced Serviceability Options for Java): . o (Advanced Garbage Collection Options for Java): (GC) Java HotSpot . (Boolean) . . -XX (-XX:+OptionName) (-XX:-OptionName) . (:) (=) ( ). k K (KB) m M (MB) g G (GB) . 8g 8192m 8388608k 8589934592 . . 0.25 . : o (Deprecated Java Options): --- . o (Obsolete Java Options): --- . o (Removed Java Options): --- . (STANDARD OPTIONS FOR JAVA) JVM . : --name=value --name value . -agentlib:libname[=options] (Native Agent Library) . . o macOS: -agentlib:foo JVM libfoo.so LD_LIBRARY_PATH ( macOS DYLD_LIBRARY_PATH ). o : -agentlib:foo JVM foo.dll PATH . (JDWP) 8000 JVM : -agentlib:jdwp=transport=dt_socket,server=y,address=8000 -agentpath:pathname[=options] . -agentlib . --class-path classpath, -classpath classpath, or -cp classpath JAR ZIP - (;) . classpath CLASSPATH . classpath (.) . (*) .jar .JAR . . mydir a.jar b.JAR mydir/* A.jar:b.JAR JAR . .jar . (*) jar . CLASSPATH . Java VM . System.getenv("CLASSPATH"). --disable-@files @filename . @ . --enable-preview (Preview Features) [https://docs.oracle.com/en/java/javase/12/language/index.html#JSLAN-GUID-5A82FE0E-0CA4-4F1F-B075-564874FE2823] . --module-path modulepath... or -p modulepath - (;) . --upgrade-module-path modulepath... - (;) . --add-modules module[,module...] . module ALL-DEFAULT ALL-SYSTEM ALL-MODULE-PATH . --list-modules . -d module_name or --describe-module module_name . --dry-run (VM) (main) . --dry-run . --validate-modules . . -Dproperty=value (System Property) . property . value . value ( -Dfoo="foo bar"). -disableassertions[:[packagename]...|:classname] or -da[:[packagename]...|:classname] (Assertions) . . -disableassertions (-da) . packagename ... . ... . classname . -disableassertions (-da) (Class Loaders) ( ) . : . . -disablesystemassertions . -enableassertions (-ea) . . MyClass com.wombat.fruitbat ( ) com.wombat.fruitbat.Brickbat : java -ea:com.wombat.fruitbat... -da:com.wombat.fruitbat.Brickbat MyClass -disablesystemassertions or -dsa . -enableassertions[:[packagename]...|:classname] or -ea[:[packagename]...|:classname] (Assertions) . . -enableassertions (-ea) . packagename ... . ... . classname . -enableassertions (-ea) ( ) . : . . -enablesystemassertions . -disableassertions (-da) . . MyClass com.wombat.fruitbat ( ) com.wombat.fruitbat.Brickbat : java -ea:com.wombat.fruitbat... -da:com.wombat.fruitbat.Brickbat MyClass -enablesystemassertions or -esa . -help, -h, or -? (stderr) . --help (stdout) . -javaagent:jarpath[=options] (Java Programming Language Agent) . java.lang.instrument . --show-version . -showversion . --show-module-resolution . -splash:imagepath (Splash Screen) imagepath . HiDPI . image.ext -splash . . splash.gif images : -splash:images/splash.gif SplashScreen API . -verbose:class . -verbose:gc (GC) . -verbose:jni (JNI) . -verbose:module . --version . -version . -X . --help-extra . @argfile @ java . java .jar classpath . @argfile . --disable-@files . . java : java @argfile @ (java Command-Line Argument Files) . (EXTRA OPTIONS FOR JAVA) java Java HotSpot . -Xbatch . JVM . -Xbatch . -XX:-BackgroundCompilation . -Xbootclasspath/a:directories|zip|JAR-files JAR ZIP (Bootstrap Class Path) . macOS: (:) . : - (;) . -Xcheck:jni (JNI) . JVM : o JVM (Attach) . o JNIEnv . o : o jfieldID jmethodID . : o o o . o . : o NULL o o UTF-8 o JNI o ReleaseXXX GetXXX : o JNI JNI . o (Lname;) . o NULL . o JNI Get/ReleasePrimitiveArrayCritical Get/ReleaseStringCritical . -Xdebug . . -Xdiag . -Xint (Interpreted-only) . . Just-In-Time (JIT) . -Xinternalversion JVM -version . -Xlog:option (JVM) . JVM (Enable Logging with the JVM Unified Logging Framework) . -Xmixed (Hot Methods) . . -Xint . -Xmn size ( ) (Young Generation / Nursery) . k K m M g G . . GC . (Minor GC) . (Full GC) . G1 25 50 . 256 : -Xmn256m -Xmn262144k -Xmn268435456 -Xmn -XX:NewSize -XX:MaxNewSize . -Xms size ( ) . 1024 1 . k K m M g G . 6 : -Xms6291456 -Xms6144k -Xms6m -Xms -XX:MinHeapSize -XX:InitialHeapSize . . -Xmn -XX:NewSize . -Xmx size ( ) . 1024 2 . k K m M g G . . -Xms -Xmx . 80 : -Xmx83886080 -Xmx81920k -Xmx80m -Xmx -XX:MaxHeapSize . -Xnoclassgc (GC) . GC . -Xnoclassgc GC . (Out of Memory) . -Xrs JVM . (Shutdown Hooks) ( ) JVM . o macOS: o JVM . JVM SIGHUP SIGINT SIGTERM . o JVM SIGINT SIGTERM JVM . -Xrs . -Xrs SIGINT SIGTERM SIGHUP SIGQUIT JVM . o : o JVM . JVM CTRL_C_EVENT CTRL_CLOSE_EVENT CTRL_LOGOFF_EVENT CTRL_SHUTDOWN_EVENT TRUE . o JVM . JVM CTRL_BREAK_EVENT . o JVM ( ) CTRL_LOGOFF_EVENT . -Xrs . -Xrs JVM CTRL_C_EVENT CTRL_CLOSE_EVENT CTRL_LOGOFF_EVENT CTRL_SHUTDOWN_EVENT . -Xrs : o macOS: SIGQUIT . o : Ctrl + Break . System.exit() JVM . -Xshare:mode (CDS) . mode : auto (). on . : -Xshare:on . CDS ( VM JDK ) . . off . -XshowSettings . -XshowSettings:category . category : all . . locale (Locale) . properties . vm JVM . system : . -Xss size (Thread Stack Size) . k K m M g G . : o /x64 ( ): 1024 o macOS ( ): 1024 o : 1024 : -Xss1m -Xss1024k -Xss1048576 -XX:ThreadStackSize . --add-reads module=target-module(,target-module)* module target-module . target-module all unnamed . --add-exports module/package=target-module(,target-module)* module (Export) package target-module . target-module all unnamed . --add-opens module/package=target-module(,target-module)* module package target-module . --limit-modules module[,module...] . --patch-module module=file(;file)* JAR . --source version . MACOS (EXTRA OPTIONS FOR MACOS) macOS . -XstartOnFirstThread main() (AppKit) . -Xdock:name=application_name (Dock) . -Xdock:icon=path_to_icon_file . (ADVANCED OPTIONS FOR JAVA) java . -XX:+UnlockDiagnosticVMOptions JVM . . . . . -XX:+UnlockExperimentalVMOptions JVM . . (ADVANCED RUNTIME OPTIONS FOR JAVA) java Java HotSpot VM . -XX:ActiveProcessorCount=x (CPU) (Thread Pools) ForkJoinPool . . CPU . UseContainerSupport . -XX:-UseContainerSupport . -XX:AllocateHeapAt=path (Memory Mapping) . HotSpot VM NV-DIMM . DRAM DRAM . ( ) DRAM . DRAM . (Page Cache) . ( -Xmx -Xms) . -XX:-CompactStrings (Compact Strings) . . ISO-8859-1 / Latin-1 . 50 . UTF-16 2 . UTF-16 . : o . o Java SE 8 Java SE 9 Compact Strings . Compact Strings . -XX:ErrorFile=filename . hs_err_pidpid.log pid . ( %p ): -XX:ErrorFile=./hs_err_pid%p.log o macOS: /var/log/java/java_error.log : -XX:ErrorFile=/var/log/java/java_error.log o : C:/log/java/java_error.log : -XX:ErrorFile=C:/log/java/java_error.log . ( ) : o macOS: /tmp . o : TMP TEMP . -XX:+ExtensiveErrorReports ErrorFile . - . . . -XX:FlightRecorderOptions=parameter=value ()-XX:FlightRecorderOptions:parameter=value JFR (Java Flight Recorder) . parameter=value JFR : globalbuffersize=size . memorysize . memorysize . maxchunksize=size ( ) (Data Chunks) . m M (MB) g G (GB) . 12 . 1 . memorysize=size globalbuffersize numglobalbuffers . m M (MB) g G (GB) . 10 . numglobalbuffers . . memorysize . old-object-queue-size=number-of-objects . 256 . repository=path ( ) . . retransform={true|false} JVMTI (Retransform) . false (Instrumentation) . . samplethreads={true|false} . . . stackdepth=depth (Stack Traces). 64 . 2048 . 64 . threadbuffersize=size ( ) . 8 4 . . . -XX:LargePageSizeInBytes=size ( ) JVM . size . k K m M g G . 0 JVM . (Large Pages) . 1 (GB) : -XX:LargePageSizeInBytes=1g -XX:MaxDirectMemorySize=size ( ) (Direct-buffer) java.nio . k K m M g G . 0 JVM NIO . NIO 1024 : -XX:MaxDirectMemorySize=1m -XX:MaxDirectMemorySize=1024k -XX:MaxDirectMemorySize=1048576 -XX:-MaxFDLimit (Soft Limit) (Hard Limit) . . Mac OS 10240 . -XX:NativeMemoryTracking=mode JVM . mode : off JVM . -XX:NativeMemoryTracking . summary JVM . detail JVM CallSite (Committed) . -XX:TrimNativeHeapInterval=millis ( ) JVM (Trim) . . 0 () . . C (glibc) . -XX:ObjectAlignmentInBytes=alignment ( ) . 8 . 2 8 256 ( ) . . : 4GB * ObjectAlignmentInBytes : . . -XX:OnError=string - . . o macOS: -XX:OnError gcore core gdb (%p ): -XX:OnError="gcore %p;gdb -p %p" o : -XX:OnError userdump.exe (%p ). userdump.exe PATH : -XX:OnError="userdump.exe %p" -XX:OnOutOfMemoryError=string - OutOfMemoryError . . -XX:OnError . -XX:+PrintCommandLineFlags JVM . JVM . . -XX:+PreserveFramePointer RBP (-XX:-PreserveFramePointer) RBP (-XX:+PreserveFramePointer) . ( Linux perf) . -XX:+PrintNMTStatistics JVM ( -XX:NativeMemoryTracking ) . . -XX:SharedArchiveFile=path (CDS) . (Application Class Data Sharing) . -XX:+VerifySharedSpaces JVM CDS CRC32 . CDS . CDS CDS . -XX:SharedArchiveConfigFile=shared_config_file . -XX:SharedClassListFile=file_name (CDS) . (/) (.) . java.lang.Object hello.Main : java/lang/Object hello/Main . . (Application Class Data Sharing) . -XX:+ShowCodeDetailsInExceptionMessages NullPointerException . NullPointerException JVM null . NullPointerException.getMessage() . . -XX:+ShowMessageBoxOnError JVM . JVM . . -XX:StartFlightRecording=parameter=value JFR . JFR.start . parameter=value JFR : delay=time . s m h d ( 10m 10 ). 0 . disk={true|false} . . dumponexit={true|false} JVM . . hotspot-pid-47496-id-1-2018_01_25_19_10_41.jfr. . duration=time . s m h d ( 5h 5 ). 0 . filename=path : o recording.jfr o /home/user/recordings/recording.jfr o c:\recordings\recording.jfr name=identifier . maxage=time . disk true . s m h d ( 30s 30 ). 0s . maxsize=size ( ) . disk true . maxchunksize -XX:FlightRecorderOptions . m M g G . 0 . path-to-gc-roots={true|false} (GC Roots) . . GC . . settings profile . settings=path ( JFC) . default.jfc JAVA_HOME/lib/jfr . . profile.jfc . . . .jfc : option=value . JAVA_HOME/bin/jfr . event-setting=value . : #= . '+' . .jfc . .jfc . 20ms. Javadoc jdk.jfr . -XX:ThreadStackSize=size ( ) . k -XX:ThreadStackSize=1k 1024*1024 1 . : o /x64 ( ): 1024 o macOS ( ): 1024 o : 1 : -XX:ThreadStackSize=1k -XX:ThreadStackSize=1024 -Xss . -XX:-UseCompressedOops (Compressed OOPs) . . . 32 . oops 64 32 oops . JVM 64 . 32 . -XX:ObjectAlignmentInBytes . -XX:-UseContainerSupport VM . . x64 . true . -XX:-UseContainerSupport . (Unified Logging) . -Xlog:os+container=trace . JVM (Enable Logging with the JVM Unified Logging Framework) . -XX:+UseHugeTLBFS : -XX:+UseLargePages . . JVM -XX:UseTransparentHugePages . (Large Pages) . -XX:+UseLargePages (Large Pages) . . (Large Pages) . -XX:+UseTransparentHugePages : . . (THP) . -XX:+AllowUserSignalHandlers . . -XX:VMOptionsFile=filename VM java -XX:VMOptionsFile=/var/my_vm_options HelloWorld. JIT (ADVANCED JIT COMPILER OPTIONS FOR JAVA) java Just-In-Time (JIT) Java HotSpot VM . -XX:AllocateInstancePrefetchLines=lines . 1 : -XX:AllocateInstancePrefetchLines=1 -XX:AllocatePrefetchDistance=size ( ) . . . () . . k K m M g G . -1 . 1024 : -XX:AllocatePrefetchDistance=1024 -XX:AllocatePrefetchInstr=instruction . 0 3 . . 0 : -XX:AllocatePrefetchInstr=0 -XX:AllocatePrefetchLines=lines (cache lines) . 1 3 . 5 : -XX:AllocatePrefetchLines=5 -XX:AllocatePrefetchStepSize=size ( ) . k K m M g G . 16 : -XX:AllocatePrefetchStepSize=16 -XX:AllocatePrefetchStyle=style . style 0 3 : 0 . 1 . . 2 (TLAB) . 3 (cache line). -XX:+BackgroundCompilation . . -XX:-BackgroundCompilation ( -Xbatch ). -XX:CICompilerCount=threads . CPU . 2 : -XX:CICompilerCount=2 -XX:+UseDynamicNumberOfCompilerThreads -XX:CICompilerCount. . -XX:CompileCommand=command,method[,option] command () method () . indexOf() String : -XX:CompileCommand=exclude,java/lang/String.indexOf (/) . (cut and paste) -XX:+PrintCompilation -XX:+LogCompilation : -XX:CompileCommand=exclude,java.lang.String::indexOf (signature) . . () - () . indexOf(String) String : -XX:CompileCommand="exclude,java/lang/String.indexOf,(Ljava/lang/String;)I" (*) (wildcard) . indexOf() : -XX:CompileCommand=exclude,*.indexOf (spaces) . -XX:CompileCommand : -XX:CompileCommand="exclude java/lang/String indexOf" JIT -XX:CompileCommand .hotspot_compiler . -XX:CompileCommandFile . -XX:CompileCommand (\n) . : break (breakpoint) JVM . compileonly . -XX:CompileOnly . dontinline (inlining) . exclude . help -XX:CompileCommand . inline . log ( -XX:+LogCompilation) . . option JIT (option) . . BlockLayoutByFrequency append() StringBuffer : -XX:CompileCommand=option,java/lang/StringBuffer.append,BlockLayoutByFrequency . print . quiet . -XX:CompileCommand indexOf() String : CompilerOracle: exclude java/lang/String.indexOf -XX:CompileCommand=quiet -XX:CompileCommand . -XX:CompileCommandFile=filename JIT . .hotspot_compiler JIT . . toString() String : print java/lang/String toString JIT -XX:CompileCommand . -XX:CompilerDirectivesFile=file (directives) . : (Compiler Control) [https://docs.oracle.com/en/java/javase/12/vm/compiler-control1.html#GUID-94AD8194-786A-4F19-BFFF-278F8E237F3A]. -XX:CompilerDirectivesFile -XX:UnlockDiagnosticVMOptions JVM . -XX:+CompilerDirectivesPrint . -XX:+CompilerDirectivesPrint -XX:UnlockDiagnosticVMOptions JVM . -XX:CompileOnly=methods ( ) . . ( ) . length() String size() List : -XX:CompileOnly=java/lang/String.length,java/util/List.size (/) . -XX:+PrintCompilation -XX:+LogCompilation : -XX:CompileOnly=java.lang.String::length,java.util.List::size (wildcards) : -XX:CompileOnly=java/lang/String -XX:CompileOnly=java/lang -XX:CompileOnly=.length -XX:CompileThresholdScaling=scale . (tiered) (nontiered) . CompileThresholdScaling 0 +Inf ( ) . CompileThresholdScaling 1.0 1.0 . CompileThresholdScaling 0 . -XX:+DoEscapeAnalysis (escape analysis) . . -XX:-DoEscapeAnalysis . -XX:InitialCodeCacheSize=size (code cache) ( ) . k K m M g G . . . 32 : -XX:InitialCodeCacheSize=32k -XX:+Inline (method inlining) . . -XX:-Inline . -XX:InlineSmallCode=size ( ) . C2 . k K m M g G . . 1000 : -XX:InlineSmallCode=1000 -XX:+LogCompilation hotspot.log . -XX:LogFile . . -XX:+LogCompilation -XX:UnlockDiagnosticVMOptions JVM . -XX:+PrintCompilation . -XX:FreqInlineSize=size ( ) (hot method) . C2 . k K m M g G . . 325 : -XX:FreqInlineSize=325 -XX:MaxInlineSize=size ( ) (cold method) . C2 . k K m M g G . 35 : -XX:MaxInlineSize=35 -XX:C1MaxInlineSize=size ( ) . C1 . k K m M g G . 35 : -XX:MaxInlineSize=35 -XX:MaxTrivialSize=size ( ) (trivial method) . C2 . k K m M g G . 6 : -XX:MaxTrivialSize=6 -XX:C1MaxTrivialSize=size ( ) . C1 . k K m M g G . 6 : -XX:MaxTrivialSize=6 -XX:MaxNodeLimit=nodes . . 100,000 : -XX:MaxNodeLimit=100000 -XX:NonNMethodCodeHeapSize=size ( ) (nonmethod code) . . . -XX:SegmentedCodeCache . -XX:NonProfiledCodeHeapSize=size ( ) (nonprofiled) . -XX:SegmentedCodeCache . -XX:+OptimizeStringConcat (concatenation) String . . String -XX:-OptimizeStringConcat . -XX:+PrintAssembly (native) hsdis-.so .dll . 64 hsdis-amd64.dll . . . -XX:+PrintAssembly -XX:UnlockDiagnosticVMOptions JVM . -XX:ProfiledCodeHeapSize=size ( ) (profiled) . -XX:SegmentedCodeCache . -XX:+PrintCompilation JVM . . . -XX:+LogCompilation . -XX:+PrintInlining (inlining) . . . -XX:+PrintInlining -XX:+UnlockDiagnosticVMOptions JVM . -XX:ReservedCodeCacheSize=size ( ) JIT . k K m M g G . 240 -XX:-TieredCompilation 48 . 2 . -XX:InitialCodeCacheSize . -XX:RTMAbortRatio=abort_ratio (abort ratio) RTM (%) RTM . (deoptimized) . -XX:+UseRTMDeopt . 50 . 50% . -XX:RTMRetryCount=number_of_retries RTM ( ) . 5 . -XX:UseRTMLocking . -XX:+SegmentedCodeCache (code cache segmentation) . -XX:+SegmentedCodeCache . -XX:+SegmentedCodeCache . . (-XX:+TieredCompilation) -XX:ReservedCodeCacheSize >= 240 MB . (fragmentation) iTLB/iCache (locality) . iTLB/iCache CPU (ITLB) . ICache CPU . : /share/vm/code/codeCache.cpp. -XX:StartAggressiveSweepingAt=percent . 10% . -XX:-TieredCompilation (tiered compilation) . . -XX:UseSSE=version SSE . ( x86). -XX:UseAVX=version AVX . ( x86). -XX:+UseAES (intrinsics) AES . . -XX:+UseAES UseAESIntrinsics . -XX:+UnlockDiagnosticVMOptions . -XX:+UseAESIntrinsics AES . -XX:+UseAESIntrinsics -XX:+UseAES . AES -XX:-UseAES -XX:-UseAESIntrinsics . AES : -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UnlockDiagnosticVMOptions . -XX:+UseAESCTRIntrinsics -XX:+UseAESIntrinsics AES/CTR . -XX:+UseGHASHIntrinsics GHASH . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseBASE64Intrinsics BASE64 java.util.Base64 . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseAdler32Intrinsics Adler32 java.util.zip.Adler32 . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseCRC32Intrinsics CRC32 java.util.zip.CRC32 . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseCRC32CIntrinsics CRC32C java.util.zip.CRC32C . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSHA SHA . UseSHA UseSHA1Intrinsics UseSHA256Intrinsics UseSHA512Intrinsics . UseSHA UseSHA*Intrinsics . sun.security.provider.Sun SHA . -XX:+UnlockDiagnosticVMOptions . SHA -XX:-UseSHA . SHA . : -XX:-UseSHA256Intrinsics. -XX:+UseSHA1Intrinsics SHA-1 . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSHA256Intrinsics SHA-224 SHA-256 . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSHA512Intrinsics SHA-384 SHA-512 . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMathExactIntrinsics (intrinsification) java.lang.Math.*Exact() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMultiplyToLenIntrinsic BigInteger.multiplyToLen() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSquareToLenIntrinsic BigInteger.squareToLen() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMulAddIntrinsic BigInteger.mulAdd() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMontgomeryMultiplyIntrinsic BigInteger.montgomeryMultiply() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMontgomerySquareIntrinsic BigInteger.montgomerySquare() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseCMoveUnconditionally CMove ( ) . -XX:+UseCodeCacheFlushing (flush) . . -XX:-UseCodeCacheFlushing . -XX:+UseCondCardMark . . . -XX:+UseCountedLoopSafepoints (safepoints) . . -XX:LoopStripMiningIter=number_of_iterations (strip mined) . . . . 1,000 . -XX:LoopStripMiningIterShortLoop=number_of_iterations . . (1/10) -XX:LoopStripMiningIter . -XX:+UseFMA FMA FMA ( Intel ARM64) . FMA java.lang.Math.fma(a, b, c) (a * b + c) . -XX:+UseRTMDeopt RTM . -XX:RTMAbortRatio . . . -XX:+UseRTMLocking . -XX:+UseRTMLocking (Restricted Transactional Memory RTM) (inflated) . . RTM CPU x86 (TSX) . RTM TSX x86 . RTM XBEGIN XABORT XEND XTEST . XBEGIN XEND . XEND (commit) . XABORT XTEST . . RTM . RTM TSX . RTM (critical region - ) . RTM (coarse-grain locking) . ( fine-grained locking .) RTM (false cache line sharing) . . . -XX:+UseSuperWord (superword) . (vectorization) . . -XX:-UseSuperWord . (ADVANCED SERVICEABILITY OPTIONS FOR JAVA) java . -XX:+DisableAttachMechanism JVM . jcmd jstack jmap jinfo . : jcmd jinfo jmap jstack JDK JDK JDK . -XX:+ExtendedDTraceProbes macOS: dtrace . dtrace . -XX:+HeapDumpOnOutOfMemoryError (heap dump) (HPROF) java.lang.OutOfMemoryError . -XX:HeapDumpPath . OutOfMemoryError . -XX:HeapDumpPath=path (HPROF) -XX:+HeapDumpOnOutOfMemoryError . java_pid.hprof . (%p ): -XX:HeapDumpPath=./java_pid%p.hprof o macOS: /var/log/java/java_heapdump.hprof : -XX:HeapDumpPath=/var/log/java/java_heapdump.hprof o : C:/log/java/java_heapdump.log : -XX:HeapDumpPath=C:/log/java/java_heapdump.log -XX:LogFile=path (log) . hotspot.log . o macOS: /var/log/java/hotspot.log : -XX:LogFile=/var/log/java/hotspot.log o : C:/log/java/hotspot.log : -XX:LogFile=C:/log/java/hotspot.log -XX:+PrintClassHistogram : o macOS: Control+Break o : Control+C (SIGTERM) . jmap -histo jcmd pid GC.class_histogram pid . -XX:+PrintConcurrentLocks java.util.concurrent : o macOS: Control+Break o : Control+C (SIGTERM) . jstack -l jcmd pid Thread.print -l pid . -XX:+PrintFlagsRanges . (Validate Java Virtual Machine Flag Arguments) . -XX:+PerfDataSaveToFile jstat . hsperfdata_pid pid . jstat : jstat -class file:///path/hsperfdata_pid jstat -gc file:///path/hsperfdata_pid -XX:+UsePerfData perfdata . JVM . hsperfdata_userid . perfdata -XX:-UsePerfData . (ADVANCED GARBAGE COLLECTION OPTIONS FOR JAVA) java (GC) Java HotSpot VM . -XX:+AggressiveHeap . ( ) . . -XX:+AlwaysPreTouch VM (touch) . (commit) . -XX:ConcGCThreads=threads (threads) GC . threads / . JVM . GC : -XX:ConcGCThreads=2 -XX:+DisableExplicitGC System.gc() . System.gc() . System.gc() JVM GC . -XX:+ExplicitGCInvokesConcurrent GC System.gc() . -XX:+UseG1GC . -XX:G1AdaptiveIHOPNumInitialSamples=number -XX:UseAdaptiveIHOP (marking) G1 -XX:InitiatingHeapOccupancyPercent . G1 -XX:InitiatingHeapOccupancyPercent . . -XX:G1HeapRegionSize=size (regions) (G1) . . . : -XX:G1HeapRegionSize=16m -XX:G1HeapWastePercent=percent . Java HotSpot VM (mixed GC) . . -XX:G1MaxNewSizePercent=percent (young generation) . . . -XX:DefaultMaxNewGenPercent . -XX:G1MixedGCCountTarget=number G1MixedGCLiveThresholdPercent . . . -XX:G1MixedGCLiveThresholdPercent=percent . . . -XX:G1OldCSetRegionLiveThresholdPercent . -XX:G1NewSizePercent=percent . . . -XX:DefaultMinNewGenPercent . -XX:G1OldCSetRegionThresholdPercent=percent . . -XX:G1ReservePercent=percent ( ) (promotion failure) G1 . . % . % : -XX:G1ReservePercent=20 -XX:+G1UseAdaptiveIHOP . G1 -XX:G1AdaptiveIHOPNumInitialSamples -XX:InitiatingHeapOccupancyPercent . -XX:InitiatingHeapOccupancyPercent . . -XX:InitialHeapSize=size ( ) . . k K m M g G . . : -XX:InitialHeapSize=6291456 -XX:InitialHeapSize=6144k -XX:InitialHeapSize=6m . -XX:NewSize . -XX:InitialRAMPercentage=percent JVM -XX:MaxRAM . . . : -XX:InitialRAMPercentage=5 -XX:InitialSurvivorRatio=ratio (survivor space) (throughput garbage collector) -XX:+UseParallelGC . throughput -XX:+UseParallelGC . ( -XX:-UseAdaptiveSizePolicy) -XX:SurvivorRatio . (S) (Y) (R) : S=Y/(R+2) . . . ( ) . . : -XX:InitialSurvivorRatio=4 -XX:InitiatingHeapOccupancyPercent=percent ( ) G1 . % . GC G1 . -XX:G1UseAdaptiveIHOP -XX:G1AdaptiveIHOPNumInitialSamples . % : -XX:InitiatingHeapOccupancyPercent=75 -XX:MaxGCPauseMillis=time GC ( ) . (soft goal) JVM . . G1 . . : -XX:MaxGCPauseMillis=500 -XX:MaxHeapSize=size ( ) . . k K m M g G . . -XX:InitialHeapSize -XX:MaxHeapSize . : -XX:MaxHeapSize=83886080 -XX:MaxHeapSize=81920k -XX:MaxHeapSize=80m -XX:MaxHeapSize -Xmx . -XX:MaxHeapFreeRatio=percent ( ) GC . . % . MaxHeapFreeRatio ( %) MinHeapFreeRatio ( %) -XX:MaxHeapFreeRatio -XX:MinHeapFreeRatio . MaxHeapFreeRatio % MinHeapFreeRatio % . . -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:-ShrinkHeapInSteps . (embedded) (Performance Tuning Examples) . -XX:MaxMetaspaceSize=size (native memory) (class metadata) . . . : -XX:MaxMetaspaceSize=256m -XX:MaxNewSize=size ( ) (nursery) . . -XX:MaxRAM=size JVM . JVM ( ). JVM ( ). oops compressed oops . compressed oops -XX:UseCompressedOops . : -XX:MaxRAM=2G -XX:MaxRAMPercentage=percent JVM ( -XX:MaxRAM ) . 25 . (compressed oops) compressed oops . -XX:UseCompressedOops . : -XX:MaxRAMPercentage=75 -XX:MinRAMPercentage=percent JVM ( -XX:MaxRAM ) . . 50 . : -XX:MinRAMPercentage=75 -XX:MaxTenuringThreshold=threshold (tenuring threshold) GC . 15 . (throughput) 15 . 10 : -XX:MaxTenuringThreshold=10 -XX:MetaspaceSize=size . . . -XX:MinHeapFreeRatio=percent ( ) GC . . 40% . MaxHeapFreeRatio ( 70%) MinHeapFreeRatio ( 40%) -XX:MaxHeapFreeRatio -XX:MinHeapFreeRatio . MaxHeapFreeRatio 10% MinHeapFreeRatio 5% . . -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:-ShrinkHeapInSteps . (embedded) (Performance Tuning Examples) . -XX:MinHeapSize=size ( ) . 0 1024 1 . k K m M g G . . 6 : -XX:MinHeapSize=6291456 -XX:MinHeapSize=6144k -XX:MinHeapSize=6m 0 . -XX:NewRatio=ratio (young generation) (old generation) . 2 . 1 : -XX:NewRatio=1 -XX:NewSize=size ( ) (nursery) . k K m M g G . . GC . GC (minor GC) . GC (full GC) . 25% 50% . 256 : -XX:NewSize=256m -XX:NewSize=262144k -XX:NewSize=268435456 -XX:NewSize -Xmn . -XX:ParallelGCThreads=threads (stop-the-world STW) . CPU JVM . G1 : -XX:ParallelGCThreads=2 -XX:+ParallelRefProcEnabled . . -XX:+PrintAdaptiveSizePolicy . . -XX:+ScavengeBeforeFullGC (full GC) . . full GC . GC full GC -XX:-ScavengeBeforeFullGC . -XX:SoftRefLRUPolicyMSPerMB=time ( ) (softly reachable) . . -XX:SoftRefLRUPolicyMSPerMB ( Java HotSpot Client) ( Java HotSpot Server) . Client VM Server VM . -Xmx . 2.5 : -XX:SoftRefLRUPolicyMSPerMB=2500 -XX:-ShrinkHeapInSteps -XX:MaxHeapFreeRatio . . . . . MaxHeapFreeRatio (Performance Tuning Examples) . -XX:StringDeduplicationAgeThreshold=threshold String (deduplication) . . (tenuring) . : String . 3 . -XX:+UseStringDeduplication . -XX:SurvivorRatio=ratio eden survivor . 8 . eden/survivor 4 : -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=percent survivor ( ) . 50% . survivor 30% : -XX:TargetSurvivorRatio=30 -XX:TLABSize=size ( ) (TLAB) . k K m M g G . 0 JVM . TLAB 512 : -XX:TLABSize=512k -XX:+UseAdaptiveSizePolicy . . -XX:-UseAdaptiveSizePolicy . -XX:SurvivorRatio . -XX:+UseG1GC (G1 Garbage- First) . . GC (throughput) . G1 ( ) GC ( . ) . G1 . -XX:+UseGCOverheadLimit JVM GC OutOfMemoryError . 98% 2% GC OutOfMemoryError . . -XX:-UseGCOverheadLimit . -XX:+UseNUMA (NUMA) . NUMA . (-XX:+UseParallelGC). -XX:+UseParallelGC (Parallel Scavenge throughput collector ) . . -XX:+UseSerialGC (Serial Garbage Collector) . . . -XX:+UseSHM : JVM (large pages) . (Large Pages) . -XX:+UseStringDeduplication (string deduplication) . . (G1) . String String . String String . -XX:+UseTLAB (TLAB) . . TLAB -XX:-UseTLAB . -XX:+UseZGC Z ( ZGC) . . . . -XX:ZAllocationSpikeTolerance=factor (allocation spike tolerance) ZGC . 2.0 . . 3.0 . -XX:ZCollectionInterval=seconds ( ) GC ZGC . 0 () . -XX:ZFragmentationLimit=percent ( ) ZGC . 25 . CPU . -XX:+ZProactive (proactive) ZGC . . ZGC GC . . -XX:+ZUncommit (uncommit) ZGC . . JVM . -XX:ZUncommitDelay=seconds ( ) (uncommit) . 300 ( ) . . . (DEPRECATED JAVA OPTIONS) java JDK . . -Xfuture . . . -Xloggc:filename GC . java -Xloggc -verbose:gc . -Xloggc:filename -Xlog:gc:filename . << JVM>> . : -Xlog:gc:garbage-collection.log -XX:+FlightRecorder (Java Flight Recorder JFR) . JDK 8u40 JFR . -XX:InitialRAMFraction=ratio JVM ( -XX:MaxRAM ) . 64 . -XX:InitialRAMPercentage . -XX:MaxRAMFraction=ratio JVM ( -XX:MaxRAM ) . 4 . (compressed oops) compressed oops . -XX:UseCompressedOops . -XX:MaxRAMPercentage . -XX:MinRAMFraction=ratio JVM ( -XX:MaxRAM ) . . 2 . -XX:MinRAMPercentage . -XX:+UseBiasedLocking (biased locking) . . . (OBSOLETE JAVA OPTIONS) java . --illegal-access=parameter (relaxed strong encapsulation) JEP 261 [https://openjdk.java.net/jeps/261#Relaxed-strong-encapsulation] . JDK 16 JEP 396 [https://openjdk.java.net/jeps/396] JDK 17 JEP 403 [https://openjdk.java.net/jeps/403] . (REMOVED JAVA OPTIONS) java JDK 17 : Unrecognized VM option option-name -XX:+UseMembar (membar) . ARM ( ) . -XX:MaxPermSize=size (permanent generation) ( ) . JDK 8 -XX:MaxMetaspaceSize . -XX:PermSize=size ( ) . JDK 8 -XX:MetaspaceSize . -XX:+TraceClassLoading . . (Unified Logging) : -Xlog:class+load=level. JVM . level=info level=debug . Unified Logging -verbose:class -Xlog:class+load=info,class+unload=info. -XX:+TraceClassLoadingPreorder . . (Unified Logging) : -Xlog:class+preorder=debug. JVM . -XX:+TraceClassResolution (constant pool resolutions) . . (Unified Logging) : -Xlog:class+resolve=debug. JVM . -XX:+TraceLoaderConstraints (loader constraints recording) . . (Unified Logging) : -Xlog:class+loader+constraints=info. JVM . Removed Java Options : o Java Platform, Standard Edition Tools Reference, Release 16 [https://docs.oracle.com/en/java/javase/16/docs/specs/man/java.html] o Java Platform, Standard Edition Tools Reference, Release 15 [https://docs.oracle.com/en/java/javase/15/docs/specs/man/java.html] o Java Platform, Standard Edition Tools Reference, Release 14 [https://docs.oracle.com/en/java/javase/14/docs/specs/man/java.html] o Java Platform, Standard Edition Tools Reference, Release 13 [https://docs.oracle.com/en/java/javase/13/docs/specs/man/java.html] o Java Platform, Standard Edition Tools Reference, Release 12 [https://docs.oracle.com/en/java/javase/12/tools/java.html#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE] o Java Platform, Standard Edition Tools Reference, Release 11 [https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-741FC470-AA3E-494A-8D2B-1B1FE4A990D1] o Java Platform, Standard Edition Tools Reference, Release 10 [https://docs.oracle.com/javase/10/tools/java.htm#JSWOR624] o Java Platform, Standard Edition Tools Reference, Release 9 [https://docs.oracle.com/javase/9/tools/java.htm#JSWOR624] o Java Platform, Standard Edition Tools Reference, Release 8 for Oracle JDK on Windows [https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html#BGBCIEFC] o Java Platform, Standard Edition Tools Reference, Release 8 for Oracle JDK on Solaris, Linux, and macOS [https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html#BGBCIEFC] (JAVA COMMAND-LINE ARGUMENT FILES) @ ( ) java java . java . (@) java . java (@) (expand) . java --disable-@files . --disable-@files @ . java : o ASCII ASCII UTF-8. o MAXINT () . o (wildcards) . o (white space) . o \t \n \r \f . c:\Program Files "c:\\Program Files" c:\Program" "Files . o ('"') . o \n \r \t \f . ASCII . o . o . o # () . # . o @ @ ( @ ). o (\) . . (\) . o (\) . o (end-of-file) . o \ . o (*) ( *.java). o (@) . (Example of Open or Partial Quotes in an Argument File) -cp "lib/ cool/ app/ jars : -cp lib/cool/app/jars (Example of a Backslash Character Escaped with Another Backslash) : -cp c:\Program Files (x86)\Java\jre\lib\ext;c:\Program Files\Java\jre9\lib\ext : -cp "c:\\Program Files (x86)\\Java\\jre\\lib\\ext;c:\\Program Files\\Java\\jre9\\lib\\ext" EOL (Example of an EOL Escape Used to Force Concatenation of Lines in an Argument File) -cp "/lib/cool app/jars:\ /lib/another app/jars" : -cp /lib/cool app/jars:/lib/another app/jars (Example of Line Continuation with Leading Spaces in an Argument File) -cp "/lib/cool\ \app/jars??? : -cp /lib/cool app/jars (Examples of Using Single Argument File) myargumentfile java : java @myargumentfile (Examples of Using Argument Files with Paths) . path1/options path2/options . : java @path1/options @path2/classes (CODE HEAP STATE ANALYTICS) (Overview) (code heap) JVM : o JIT o o (method sweeper) (on-the-fly) . . . . << >> (on request) . (Syntax) : jcmd pid Compiler.CodeHeap_Analytics [function] [granularity] : -Xlog:codecache=Trace <> ( ) : -Xlog:codecache=Debug (granularity) CodeHeap State Analytics (OpenJDK) [https://bugs.openjdk.java.net/secure/attachment/75649/JVM_CodeHeap_StateAnalytics_V2.pdf] . JVM (ENABLE LOGGING WITH THE JVM UNIFIED LOGGING FRAMEWORK) -Xlog (JVM) . (Synopsis) -Xlog[:[what][:[output][:[decorators][:output-options[,...]]]]] -Xlog:directive what tag1[+tag2...][*][=level][,...] . (*) . -Xlog (-Xlog Tags and Levels) . output . output stdout . -Xlog (-Xlog Output) . decorators . decorators uptime level tags . (Decorations) . output-options -Xlog . directive : help disable async (Description) (JVM) JVM . (GC) JVM . GC Xlog GC Xlog . (runtime logging) JVM . Xlog Xlog . -Xlog : -Xlog JVM info . -Xlog:help -Xlog . -Xlog:disable . -Xlog[:option] . -Xlog (override) . option : [tag-selection][:[output][:[decorators][:output-options]]] tag-selection all info . tag[+...] all all . * (wildcard) . . . output-options filecount=file-count filesize= K M G (Default Configuration) -Xlog . warning error . : -Xlog:all=warning:stdout:uptime,level,tags (Controlling Logging at Runtime) ( jcmd) . VM.log . MBean JMX . -Xlog (-Xlog Tags and Levels) . JVM ( gc jit os) . GC Xlog GC Xlog . Xlog Xlog . : o off o trace o debug o info o warning o error : . -Xlog:help . all . -Xlog (-Xlog Output) -Xlog : o stdout --- (stdout) o stderr --- (stderr) o file=filename --- () . file=filename %p / %t PID JVM . (file rotation) . filesize=10M, filecount=5 . . . filecount=0 . . -Xlog (-Xlog Output Mode) (synchronously) . (asynchronous) : -Xlog:async . (thread) (flush) . (bounded) . (non-blocking) . -XX:AsyncLogBufferSize=N . . . (Decorations) . . . . . : [6.567s][info][gc,old] Old collection complete decorators uptime level tags . none . time (t) utctime (utc) uptime (u) timemillis (tm) uptimemillis (um) timenanos (tn) uptimenanos (un) hostname (hn) pid (p) tid (ti) level (l) tags (tg) none . -------------------------------------------------------------------------------- time t ISO-8601. utctime utc (UTC). uptime u JVM . 6.567s. timemillis tm System.currentTimeMillis() . uptimemillis um JVM. timenanos tn System.nanoTime() . uptimenanos un JVM. hostname hn (hostname). pid p (process identifier). tid ti (thread identifier). level l . tags tg . Xlog (Convert GC Logging Flags to Xlog) Xlog (GC) ---------------------------------------------------------------------------------------------------- G1PrintHeapRegions -Xlog:gc+region=trace GCLogFileSize . NumberOfGCLogFiles . PrintAdaptiveSizePolicy -Xlog:gc+ergo*=level level debug level trace PrintAdaptiveSizePolicy . PrintGC -Xlog:gc PrintGCApplicationConcurrentTime -Xlog:safepoint PrintGCApplicationConcurrentTime PrintGCApplicationStoppedTime . PrintGCApplicationStoppedTime -Xlog:safepoint PrintGCApplicationConcurrentTime PrintGCApplicationStoppedTime . PrintGCCause GC . PrintGCDateStamps . PrintGCDetails -Xlog:gc* PrintGCID GC . PrintGCTaskTimeStamps -Xlog:gc+task*=debug PrintGCTimeStamps . PrintHeapAtGC -Xlog:gc+heap=trace PrintReferenceGC -Xlog:gc+ref*=debug PrintReferenceGC PrintGCDetails . PrintStringDeduplicationStatistics -Xlog:gc+stringdedup*=debug PrintTenuringDistribution -Xlog:gc+age*=level level debug level trace PrintTenuringDistribution . UseGCLogFileRotation . Xlog (Convert Runtime Logging Flags to Xlog) . (Unified Logging) . Xlog ---------------------------------------------------------------------------------------------------------- TraceExceptions -Xlog:exceptions=info TraceClassLoading -Xlog:class+load=level level=info level=debug . -verbose:class -Xlog:class+load=info,class+unload=info . TraceClassLoadingPreorder -Xlog:class+preorder=debug TraceClassUnloading -Xlog:class+unload=level level=info level=trace . -verbose:class -Xlog:class+load=info,class+unload=info . VerboseVerification -Xlog:verification=info TraceClassPaths -Xlog:class+path=info TraceClassResolution -Xlog:class+resolve=debug TraceClassInitialization -Xlog:class+init=info TraceLoaderConstraints -Xlog:class+loader+constraints=info TraceClassLoaderData -Xlog:class+loader+data=level level=debug level=trace . TraceSafepointCleanupTime -Xlog:safepoint+cleanup=info TraceSafepoint -Xlog:safepoint=debug TraceMonitorInflation -Xlog:monitorinflation=debug TraceBiasedLocking -Xlog:biasedlocking=level level=info level=trace . TraceRedefineClasses -Xlog:redefine+class*=level level=info debug trace . -Xlog (-Xlog Usage Examples) -Xlog . -Xlog info stdout uptime levels tags . : -Xlog:all=info:stdout:uptime,levels,tags -Xlog:gc gc info stdout . warning . -Xlog:gc,safepoint gc safepoint info stdout . gc safepoint . -Xlog:gc+ref=debug gc ref debug stdout . . -Xlog:gc=debug:file=gc.txt:none gc debug gc.txt . warning . -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024 gc trace gctrace.txt uptimemillis pid . warning . -Xlog:gc::uptime,tid gc 'info' stdout uptime tid . warning . -Xlog:gc*=info,safepoint*=off gc info safepoint . gc safepoint . -Xlog:disable -Xlog:safepoint=trace:safepointtrace.txt safepoint trace safepointtrace.txt . -Xlog:disable . -Xlog (Complex -Xlog Usage Examples) -Xlog . -Xlog:gc+class*=debug gc class debug stdout . warning . -Xlog:gc+meta*=trace,class*=off:file=gcmetatrace.txt gc meta trace metatrace.txt class . gc meta class class* . warning class . -Xlog:gc+meta=trace gc meta trace stdout . warning . -Xlog:gc+class+heap*=debug,meta*=warning,threads*=off gc class heap trace stdout meta . warning threads . (VALIDATE JAVA VIRTUAL MACHINE FLAG ARGUMENTS) (JVM) . API ( java.lang.management) (JVM) . HotSpot . JVM ( jcmd) . JVM . JVM : java -XX:AllocatePrefetchStyle=5 -version intx AllocatePrefetchStyle=5 is outside the allowed range [ 0 ... 3 ] Improperly specified VM option 'AllocatePrefetchStyle=5' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. -XX:+PrintFlagsRanges . . . : intx ThreadStackSize [ 0 ... 9007199254740987 ] {pd product} . : size_t NewSize [ ... ] {product} . . (LARGE PAGES) (Large Pages) (Huge Pages) ( ). (Translation-Lookaside Buffers / TLB) . (TLB) . TLB . TLB ( TLB miss) . TLB . TLB . . (Pin) (Paging) . (Fragmentation) . JVM . . (Large Pages Support for Linux) 2.6 . : # cat /proc/meminfo | grep Huge HugePages_Total: 0 HugePages_Free: 0 ... Hugepagesize: 2048 kB "Huge" . . Hugepagesize . . : # ls /sys/kernel/mm/hugepages/ hugepages-1048576kB hugepages-2048kB 2 1 JVM . ( -XX:+UseTransparentHugePages) . 8 2 root : # echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages nr_hugepages . -XX:+UseSHM SHMMAX . 8 root : # echo 8589934592 > /proc/sys/kernel/shmmax . : /proc /sys ( rc.local sysctl.conf) . : o (Code cache) o (Marking bitmaps) nr_hugepages JVM . (Large Pages Support for Windows) : 1. Control Panel Administrative Tools Local Security Policy . 2. Local Policies User Rights Assignment . 3. Lock pages in memory . 4. (Reboot) . . (APPLICATION CLASS DATA SHARING) (AppCDS) . ( JAR) AppCDS . AppCDS . CDS 2 5 JAR JDK . . . API . CDS (Using CDS Archives) JDK -Xshare:off JVM CDS JAVA_HOME/lib/server/classes.jsa ( JAVA_HOME\bin\server\classes.jsa ) . 1300 . CDS -XX:SharedArchiveFile : -XX:SharedArchiveFile=: o CDS . o . o : ; . ( "" "" . "" "" ). JVM . : -XX:SharedArchiveFile= . : -XX:SharedArchiveFile= CDS (Creating CDS Archives) CDS : o -Xshare:dump o -XX:ArchiveClassesAtExit o jcmd VM.cds " " . CDS -Xshare:dump (Creating a Static CDS Archive File with -Xshare:dump) CDS test.Hello . 1. test.Hello . hello.classlist : java -Xshare:off -XX:DumpLoadedClassList=hello.classlist -cp hello.jar test.Hello -cp JAR . 2. hello.jsa hello.classlist : java -Xshare:dump -XX:SharedArchiveFile=hello.jsa -XX:SharedClassListFile=hello.classlist -cp hello.jar 3. test.Hello hello.jsa : java -XX:SharedArchiveFile=hello.jsa -cp hello.jar test.Hello 4. : test.Hello hello.jsa : java -XX:SharedArchiveFile=hello.jsa -cp hello.jar -Xlog:class+load test.Hello : [info][class,load] test.Hello source: shared objects file CDS -XX:SharedArchiveFile (Creating a Dynamic CDS Archive File with -XX:SharedArchiveFile) CDS : o . o . CDS test.Hello CDS . 1. CDS hello.jsa hello.jar test.Hello : java -XX:ArchiveClassesAtExit=hello.jsa -cp hello.jar Hello 2. test.Hello hello.jsa : java -XX:SharedArchiveFile=hello.jsa -cp hello.jar test.Hello 3. : 4 test.Hello hello.jsa . CDS . : java -XX:SharedArchiveFile=base.jsa -XX:ArchiveClassesAtExit=hello.jsa -cp hello.jar Hello CDS: java -XX:SharedArchiveFile=base.jsa:hello.jsa -cp hello.jar Hello ( : ; ) : java -XX:SharedArchiveFile=hello.jsa -cp hello.jar Hello CDS jcmd (Creating CDS Archive Files with jcmd) CDS . . jcmd VM.cds JVM CDS . : jcmd VM.cds static_dump my_static_archive.jsa : jcmd VM.cds dynamic_dump my_dynamic_archive.jsa : env JAVA_TOOL_OPTIONS=-XX:SharedArchiveFile=my_static_archive.jsa bash app_start.sh : jcmd VM.cds dynamic_dump JVM -XX:+RecordDynamicDumpInfo : env JAVA_TOOL_OPTIONS=-XX:+RecordDynamicDumpInfo bash app_start.sh (Restrictions on Class Path and Module Path) o (-classpath -Xbootclasspath/a) (--module-path) . o JAR --module-path . (Exploded modules) . o ( ) . ( ). o JAR CDS . o VM --upgrade-module-path --patch-module --limit-modules CDS . JVM CDS . 3 CDS JVM . (PERFORMANCE TUNING EXAMPLES) . (Tuning for Higher Throughput) : java -server -XX:+UseParallelGC -XX:+UseLargePages -Xmn10g -Xms26g -Xmx26g (Tuning for Lower Response Time) : java -XX:+UseG1GC -XX:MaxGCPauseMillis=100 (Keeping the Java Heap Small and Reducing the Dynamic Footprint of Embedded Applications) : -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 : 70 40 . . (EXIT STATUS) JVM . API System.exit(exitValue) . : o 0: o >0: JDK 17 2021 JAVA(1)