-
-
Save wangwenchao/6fcd9722937bc1adc3fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export LANG="en_US.UTF-8" | |
MC=/Users/steve/Minecraft | |
# Many of these options are explaiend here: | |
# http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html | |
# http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html | |
# http://blog.ragozin.info/2011/09/hotspot-jvm-garbage-collection-options.html | |
# Also see the following link for minecraft specific Java opts: | |
# http://pastebin.com/rY3gPVGE | |
# This ensures we're using the server vm. | |
JAVA_OPTS="-server" | |
# Define a specific max and min heap. Do not use with -XX:+AggressiveHeap. | |
#JAVA_OPTS="$JAVA_OPTS -Xmx2G -Xms2G" | |
JAVA_OPTS="$JAVA_OPTS -Xmx4G -Xms512M" | |
#JAVA_OPTS="$JAVA_OPTS -XX:PermSize=128M -XX:MaxPermSize=128M -Xmn1600m" | |
# Modified Catalina benchmarks | |
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=128m -XX:MaxPermSize=256m -XX:InitiatingHeapOccupancyPercent=80" | |
#### See: http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html#Imp | |
#### Oracle only recommends fiddling with thee on G1GC: | |
# For changing the marking threshold. | |
#JAVA_OPTS="$JAVA_OPTS -XX:InitiatingHeapOccupancyPercent" | |
# When you want to change the mixed garbage collections decisions. | |
#JAVA_OPTS="$JAVA_OPTS -XX:G1MixedGCLiveThresholdPercent -XX:G1HeapWastePercent" | |
# When you want to adjust the CSet for old regions. | |
#JAVA_OPTS="$JAVA_OPTS -XX:G1MixedGCCountTarget -XX:G1OldCSetRegionThresholdPercent" | |
# To increase the amount of reserve memory for "to-space". | |
#JAVA_OPTS="$JAVA_OPTS -XX:G1ReservePercent" | |
# Start the marking cycle earlier by reducing this. | |
#JAVA_OPTS="$JAVA_OPTS -XX:InitiatingHeapOccupancyPercent" | |
# To increase the number of parallel marking threads. | |
#JAVA_OPTS="$JAVA_OPTS -XX:ConcGCThreads" | |
#### End of Oracle recommenation | |
# This option instructs the JVM to push memory use to the limit (use with | |
# caution). This option appears to conflict with -XX:+UseG1GC. | |
#JAVA_OPTS="$JAVA_OPTS -XX:+AggressiveHeap" | |
# Reduce stack requirements (use with -XX:+AggressiveHeap). | |
#JAVA_OPTS="$JAVA_OPTS -Xss" | |
# Garbge Collector: G1GC. Also, additional GC logging and disabled System.gc() | |
# calls, if any (usually, SMP only calls System.gc() when the "nogui" app parameter | |
# is absent). | |
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails -Xloggc:server_gc.log -XX:+UseG1GC" | |
#JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC" | |
# Another garvage collector option (exclusive, pick G1GC or this). | |
#JAVA_OPTS="$JAVA_OPTS -Xloggc:server_gc.log -XX:+UseParallelOldGC -XX:+DisableExplicitGC" | |
# Sets a target for the maximum GC pause time. This is a soft goal, and the JVM | |
# will make its best effort to achieve it. Therefore, the pause time goal will | |
# sometimes not be met. The default value is 200 milliseconds. | |
#JAVA_OPTS="$JAVA_OPTS -XX:MaxGCPauseMillis=200" | |
# Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It | |
# is used by G1 to trigger a concurrent GC cycle based on the occupancy of the | |
# entire heap, not just one of the generations. A value of 0 denotes 'do | |
# constant GC cycles'. The default value is 45 (i.e., 45% full or occupied). | |
# Use optimized versions of Get<Primitive>Field. | |
#JAVA_OPTS="$JAVA_OPTS -XX:InitiatingHeapOccupancyPercent=0" | |
# Use optimized versions of Get<Primitive>Field. | |
JAVA_OPTS="$JAVA_OPTS -XX:+UseFastAccessorMethods" | |
# This flag defaults to 1000, and can cause memory leaks. | |
#JAVA_OPTS="$JAVA_OPTS -XX:SoftRefLRUPolicyMSPerMB=0" | |
# This flag defaults to 1000, and can cause memory leaks. | |
#JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=80" | |
# Survivor target ratio. Java defaults to 50%, which wastes a lot of space. If | |
# you know how much you need (see below), you can set this value higher; this | |
# gives less waste and "better performance". | |
#JAVA_OPTS="$JAVA_OPTS -XX:TargetSurvivorRatio=90" | |
# Tells Java when to convert bytecode into compiled code. Server defaults to | |
# something like 15,000, which is appropriate for something that will run for | |
# months, and horrible for something that will run for a few hours. Non-server | |
# defaults to ... 1000? 1500? Much lower. | |
#JAVA_OPTS="$JAVA_OPTS -XX:CompileThreshold=300" | |
# Tells the garbage collector to break the job into many small parts. May | |
# result in better performance. Essential on systems with few cores. | |
###JAVA_OPTS="$JAVA_OPTS -XX:+CMSIncrementalMode" | |
# Apparently, adjust the boundary between new and tenured as needed. | |
#JAVA_OPTS="$JAVA_OPTS -XX:+UseAdaptiveGCBoundary" | |
#JAVA_OPTS="$JAVA_OPTS -XX:MaxHeapFreeRatio=25 -XX:MinHeapFreeRatio=21" | |
# Enables caching of commonly allocated strings. | |
JAVA_OPTS="$JAVA_OPTS -XX:+UseStringCache" | |
# Optimize String concatenation operations where possible. | |
JAVA_OPTS="$JAVA_OPTS -XX:+OptimizeStringConcat" | |
# Enables the use of compressed pointers (object references represented as 32 bit | |
# offsets instead of 64-bit pointers) for optimized 64-bit performance with Java | |
# heap sizes less than 32gb. | |
# Also see: https://wikis.oracle.com/display/HotSpotInternals/CompressedOops | |
#JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops" | |
# Pre-touch the Java heap during JVM initialization. Every page of the heap is | |
# thus demand-zeroed during initialization rather than incrementally during | |
# application execution. | |
#JAVA_OPTS="$JAVA_OPTS -XX:+AlwaysPreTouch" | |
# Inline a previously compiled method only if its generated native code size is | |
# less than this. | |
# Default: 1000 | |
#JAVA_OPTS="$JAVA_OPTS -XX:InlineSmallCode=8000" | |
# Print message about inlined methods (debug only). | |
#JAVA_OPTS="$JAVA_OPTS -XX:+PrintInlining" | |
#JAVA_OPTS="$JAVA_OPTS -XX:+PrintCompilation" | |
#JAVA_OPTS="$JAVA_OPTS -XX:+UnlockDiagnosticVMOptions -Xbatch" | |
# TESTING ONLY Force full gc at every Nth exit from the runtime system | |
# (N=FullGCALotInterval, default: 1) | |
#XXXJAVA_OPTS="$JAVA_OPTS -XX:+FullGCALot" | |
# Maximum number of bytecode instructions in a method which gets inlined. | |
#JAVA_OPTS="$JAVA_OPTS -XX:MaxInlineSize=270" | |
# Maximum number of bytecode instructions in a frequently executed method which | |
# gets inlined. | |
#JAVA_OPTS="$JAVA_OPTS -XX:FreqInlineSize=5000" | |
# Enable biased locking. http://www.oracle.com/technetwork/java/tuning-139912.html#section4.2.5 | |
JAVA_OPTS="$JAVA_OPTS -XX:+UseBiasedLocking" | |
# Use large page memory. http://www.oracle.com/technetwork/java/javase/tech/largememory-jsp-137182.html | |
# [CONFLICT] Causes error: "Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 22)." | |
#JAVA_OPTS="$JAVA_OPTS -XX:+UseLargePages" | |
# Enables the Java heap to take advantage of Non-Uniform-Memory-Architectures. | |
# JAVA will place data structures relevant to the thread which it owns / | |
# operates on, in memory locations closest to that particular processor. | |
# Depending on the environment, gains can be substantial. Intel market NUMA as | |
# Quick Path Interconnect. | |
# Also see: https://blogs.oracle.com/jonthecollector/entry/help_for_the_numa_weary | |
JAVA_OPTS="$JAVA_OPTS -XX:+UseNUMA" | |
# Disable class garbage collection. Use of this option will prevent memory | |
# recovery from loaded classes thus increasing overall memory usage. This could | |
# cause OutOfMemoryError to be thrown in some applications. | |
JAVA_OPTS="$JAVA_OPTS -Xnoclassgc" | |
# Use a byte[] for Strings which can be represented as pure ASCII. (Introduced | |
# in Java 6 Update 21 Performance Release) | |
# Option removed in Java 7. | |
#JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedStrings" | |
# Unroll loop bodies with server compiler intermediate representation node count | |
# less than this value. The limit used by the server compiler is a function of | |
# this value, not the actual value. The default value varies with the platform | |
# on which the JVM is running. | |
#JAVA_OPTS="$JAVA_OPTS -XX:LoopUnrollLimit=45" | |
# | |
# VM Triggers | |
# | |
JAVA_OPTS="$JAVA_OPTS -XX:OnError=$MC/scripts/jvm_on_error.sh" | |
JAVA_OPTS="$JAVA_OPTS -XX:OnOutOfMemoryError=$MC/scripts/jvm_on_out_of_memory.sh" | |
#JAVA_OPTS="$JAVA_OPTS -Dhttp.socksProxyHost=127.0.0.1 -Dhttp.socksProxyPort=9050" | |
# Causes the VM to pause at startup time and wait for the pause file to be | |
# removed (default: ./vm.paused.) | |
#JAVA_OPTS="$JAVA_OPTS -XX:PauseAtStartup" | |
screen -dmS minecraft nice -19 java $JAVA_OPTS -jar minecraft_server.jar nogui | |
#java $JAVA_OPTS -jar minecraft_server.jar nogui | |
#echo $JAVA_OPTS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment