Less common used java parameters
| 2 minute read | Using 337 words
Collection of less used parameters passed to java process.
Aggregated list of less used java parameters, may be useful in some cases.
-
-XX:OnOutOfMemoryError:
- Usage: Specify a script or command to execute when an OutOfMemoryError occurs.
- Example:
This command will kill the Java process (%p) when an OutOfMemoryError is encountered.
java -XX:OnOutOfMemoryError="kill -9 %p"
-
-XX:SoftRefLRUPolicyMSPerMB:
- Usage: Adjust the soft reference LRU policy based on memory consumption.
- Example:
This sets the policy to clear soft references more aggressively when memory consumption exceeds 1000 milliseconds per MB.
java -XX:SoftRefLRUPolicyMSPerMB=1000
-
-XX:MaxDirectMemorySize:
- Usage: Set the maximum size of direct memory available to your application.
- Example:
This limits the direct memory to 256 megabytes.
java -XX:MaxDirectMemorySize=256m -jar myapp.jar
-
-XX:MaxMetaspaceSize:
- Usage: Set an upper limit on the size of the metaspace, which stores class metadata.
- Example:
This caps the metaspace at 128 megabytes.
java -XX:MaxMetaspaceSize=128m -jar myapp.jar
-
-XX:ThreadStackSize:
- Usage: Adjust the stack size for Java threads.
- Example:
This sets the thread stack size to 256 kilobytes.
java -XX:ThreadStackSize=256k -jar myapp.jar
-
-XX:+UseBiasedLocking:
- Usage: Enable biased locking, which can improve performance in some cases by reducing synchronization overhead.
- Example:
This enables biased locking for the application.
java -XX:+UseBiasedLocking -jar myapp.jar
-
-XX:+UseLargePages:
- Usage: Enable the use of large memory pages to improve memory management performance.
- Example:
This enables large memory pages for the JVM.
java -XX:+UseLargePages -jar myapp.jar
-
-XX:AllocateHeapAt:
- Usage: Specify the base address for the heap (used with certain operating systems).
- Example:
This sets the base address of the heap memory.
java -XX:AllocateHeapAt=0x0000000100000000 -jar myapp.jar
-
-XX:FlightRecorderOptions:
- Usage: Configure Java Flight Recorder (JFR) options for advanced profiling and diagnostics.
- Example:
This enables default JFR recording.
java -XX:FlightRecorderOptions=defaultrecording=true -jar myapp.jar
-
-XX:MaxFDLimit:
- Usage: Set the maximum number of file descriptors that can be opened by the JVM.
- Example:
This increases the maximum file descriptor limit to 8192 for the application.
java -XX:MaxFDLimit=8192 -jar myapp.jar
These less commonly used Java parameters can be helpful in specific situations where fine-tuning or advanced configuration is necessary. However, they should be used with caution, as improper settings can impact application performance and stability.
Page link: /posts/less-common-java-params/