Java startup parameters in a detailed

Source: Internet
Author: User
Tags garbage collection jboss jboss application server ssl connection

JAVA--JVM Parameters for Startup
The first is the standard parameter (-), all JVM implementations must implement the functions of these parameters, and backward compatibility;
The second is the non-standard parameter (-X), the default JVM implements the functions of these parameters, but does not guarantee that all JVM implementations are satisfied, and does not guarantee backward compatibility;
The third is the non-stable parameter (-XX), such parameters of each JVM implementation will be different, in the future may be canceled at any time, need to use cautiously;

? The standard parameters are more useful:
Verbose
-verbose:class
Outputs information about the JVM loading classes that can be diagnosed when the JVM reports that a class or class violation is not found.
-verbose:gc
Outputs the correlation of each GC.
-verbose:jni
The output native method invocation is typically used to diagnose JNI invocation error messages.

? Non-standard parameters are also known as extended parameters
The most common use is
The-XMS512M:JVM heap memory initial value is 512M.
The maximum available memory for-XMX512M:JVM heap memory is 512M.
-xmn200m: Set the young generation size to 200M. The entire heap size = younger generation size + old generation size + persistent generation size (the total partition in the virtual machine is three generations: young Generation, Old Generation, and persistent (Permanent Generation). The persistent generation primarily stores the class information of the Java class, which is not related to the Java objects collected by garbage collection. The division of the younger generation and the old generation is more significant for garbage collection. )。 The permanent average fixed size is 64m, so increasing the younger generation will reduce the size of older generations. This value has a large impact on system performance, and Sun's official recommendation is 3/8 for the entire heap.
Young generations:
All newly generated objects are first placed in the younger generation. The goal of the young generation is to collect as quickly as possible those objects with short life cycles. The young generation is divided into three districts. One Eden area, two survivor districts (in general). Most objects are generated in the Eden area. When the Eden Zone is full, the surviving objects will be copied to the Survivor area (one of two), and when the survivor area is full, the surviving objects of this area will be copied to another survivor area, when the survivor is full, Objects that are copied from the first survivor area and that are still alive will be duplicated in the old Age zone (tenured). It should be noted that the two areas of the survivor are symmetrical and have no relationship, so the same area may exist at the same time from Eden copied objects, and from the previous survivor copied objects, and copied to the old quarter only from the first survivor to come over the object. Moreover, there is always an empty survivor area. At the same time, according to the program needs, the survivor area can be configured as multiple (more than two), which can increase the time of the object in the younger generation, reduce the possibility of being put into the old generation.
Old generation:
Objects that survived after n garbage collection in the younger generation will be placed in the old age. Therefore, it can be considered that older generations are storing objects with longer life cycles.
Persistent Generations:
Used to store static files, now Java classes, methods, and so on. The persistence generation has no significant impact on garbage collection, but some applications may dynamically generate or invoke some classes, such as Hibernate, at which point a large, persistent generation space is required to store the new class in these runs. The persistent generation size is set by-xx:maxpermsize=<n>.
Scavenge GC
In general, when a new object is generated and the Eden application space fails, the scavenge GC is triggered, GC is performed on the Eden Zone, the non-surviving objects are cleared, and the surviving objects are moved to the survivor area. Then tidy up the two districts of survivor. This method of GC is carried out on the young generation of the Eden area and does not affect the old generation. Because most objects start in the Eden area, and the Eden area is not very large, GC in the Eden area is frequent. Thus, it is generally necessary to use fast and efficient algorithms, so that Eden can be free as soon as possible.
Full GC
Organize the entire heap, including young, tenured and perm. The full GC is slower than the scavenge GC because it needs to be recycled for the entire pair, so it should be as low as possible. In the process of tuning the JVM, a large part of the work is to adjust the FULLGC. The full GC may be caused by the following reasons:
· The old generation (tenured) was written full
· Persistent generation (Perm) is full
· System.GC () is displayed call
• Dynamic changes in the domain allocation policy of the heap after the last GC

-xss128k: Sets the stack size for each thread. After JDK5.0, each thread has a stack size of 1M, before each thread has a stack size of 256K. Adjusts according to the size of the memory required by the application's thread. In the same physical memory, reducing this value can generate more threads. However, the operating system of the number of threads within a process is still limited, can not be generated indefinitely, the empirical value of 3000~5000 around.
-xloggc:file
Similar to the-VERBOSE:GC feature, just log the correlation of each GC event to a file, preferably locally, to avoid potential problems with the network.
If the verbose command appears on the command line at the same time, the-XLOGGC will prevail.
-xprof
Keep track of running programs and trace data in standard output, suitable for development environment debugging.
? Non-stable parameters
The list of parameters prefixed with-XX may not be robust in the JVM, Sun is not recommended, and may be canceled without notice, but many of these parameters are useful to us, such as the-xx:permsize and-xx that we often see: MaxPermSize and so on;

First, let's introduce the behavior parameters:

Parameters and their default value descriptions
-XX:-DISABLEEXPLICITGC prohibit calling System.GC (), but the JVM's GC is still valid
-xx:+maxfdlimit limit of maximum file descriptors
-XX:+SCAVENGEBEFOREFULLGC Generation GC takes precedence over full GC execution
-xx:+usegcoverheadlimit limits the amount of time the JVM spends on GC before throwing an Oom
-XX:-USECONCMARKSWEEPGC for GC using concurrent tag switching algorithm for Laosheng generation
-XX:-USEPARALLELGC enabling parallel GC
-XX:-USEPARALLELOLDGC enables parallelism on full GC, which is automatically enabled when-XX:-USEPARALLELGC is enabled
-XX:-USESERIALGC Enable serial GC
-xx:+usethreadpriorities Enable local thread priority
-xx:+ parallelgcthreads JVM in parallel GC, the number of threads used for GC

The three parameters of the blackbody in the table above represent three ways that the GC executes in the JVM, namely serial, parallel, concurrency;
Serial (SERIALGC) is the default GC mode of the JVM, which is generally suitable for small applications and single processors, the algorithm is simple and the GC is more efficient, but it may bring pause to the application.
Parallel (PARALLELGC) refers to the GC runtime, no impact on the application run, GC and app both threads are executing concurrently, so as to minimize the impact of the app operation;
Concurrency (CONCMARKSWEEPGC) is a multi-thread concurrent execution GC, generally applicable to multiprocessor systems, can improve the efficiency of GC, but the algorithm is complex, the system consumes large;

Performance Tuning parameter list:

Parameters and their default value descriptions
-xx:largepagesizeinbytes=4m setting a large page size for the Java heap
Maximum percentage of idle in Java heap after-xx:maxheapfreeratio=70 GC
-xx:maxnewsize=size the maximum amount of memory that a new generated object can occupy
-xx:maxpermsize=64m the maximum amount of memory that a Laosheng object can occupy
Minimum percentage of idle amount in Java heap after-xx:minheapfreeratio=40 GC
-xx:newratio=2 the ratio of cenozoic memory capacity to Laosheng memory capacity
-xx:newsize=2.125m the default value of memory used when generating new generation objects
-XX:RESERVEDCODECACHESIZE=32M Reserve the amount of memory the code occupies
-XX:THREADSTACKSIZE=512 set the thread stack size, using the system default value if 0
-xx:+uselargepages using large page memory
-xx:+usecompressedoops can compress pointers and play a new parameter to save memory consumption

In the daily performance tuning we will basically use the above properties of the blackbody;

Debug parameter list:

Parameters and their default value descriptions
-xx:-citime print consumption at JIT compile time
-xx:errorfile=./hs_err_pid<pid>.log Save error log or data to file
-xx:-extendeddtraceprobes opening a Solaris-specific dtrace probe
-xx:-traceclassunloading is used to print the process information that the class is loaded and unloaded, which is useful for diagnosing memory leak problems in your application
-XX:HEAPDUMPPATH=./JAVA_PID&LT;PID&GT;.HPROF specifies the path or file name when the heap information is exported
-xx:-heapdumponoutofmemoryerror Export the relevant information in this heap when an oom is first encountered
-xx:onerror= "<cmd args>;<cmd args>" After a fatal error running the custom command
-xx:onoutofmemoryerror= "<cmd args>;<cmd args>" executes a custom command when an oom is first encountered
-XX:-P rintclasshistogram The column information of the print class instance after Ctrl-break, same as Jmap-histo function
-XX:-P rintconcurrentlocks information about printing concurrent locks after ctrl-break, same as jstack-l function
-XX:-P Rintcommandlineflags Print the markup that appears on the command line
-xx:-P rintcompilation Printing related information When a method is compiled
-xx:-P RINTGC Printing related information per GC
-XX:-P rintgcdetails Print details per GC
-XX:-P rintgctimestamps Print timestamp for each GC
-xx:-Printgcdatestamps Print the timestamp of each GC (in the form of a date, such as 2013-05-04t21:53:59.234+0800)
-xx:-traceclassloading Tracking class Loading information
-xx:-traceclassloadingpreorder tracking load information for all classes referenced to
-xx:-tracecla***esolution Tracking Constant Pool
-xx:-traceclassunloading The unload information of the tracking class
-xx:-traceloaderconstraints Tracking class loader constraints related information
-xx:-usegclogfilerotation Enable automatic dump of GC log files
-xx:-number of Cycles Numberofgclogfiles GC log files
-xx:-Gclogfilesize Control the size of the GC log file

JBoss Boot Configuration parameters
-c,–configuration=<name> Set the server configuration name
-b,–host=-g,–partition=<name> the name of the HA partition name cluster (default=defaultdomain)
-u,–udp=<ip> multicast addresses for node interactions within a UDP multicast address cluster
-d<name>[=<value>] Set a system property parameter-D sets the value of the system Properties Jboss.messaging.ServerPeerId, which the JBoss message requires unique in the group

JMX (Java Management Extensions, Java Management extension)
-dcom.sun.management.jmxremote.ssl=false
#enable SSL Connection (True/false)
#禁止ssl连接
-dcom.sun.management.jmxremote.authenticate=true
#connection Authenticate (True/false)
#开启用户认证
-djava.rmi.server.hostname
#multi ETH Choose (ip/domain)
#指定hostname general need to reassign hostname, otherwise the connection is unsuccessful
-dcom.sun.management.jmxremote.port
#jmx Connection Remote Port
#指定hostname Specify port default: 1099
-dcom.sun.management.jmxremote.access.file
#remote Access roles (file path)
#访问模式
-dcom.sun.management.jmxremote.password.file
#remote authenticate file when authenticate enable (file path)
#认证用户名密码
Note: The Jmxremote.password and jmxremote.access files only allow the startup user name to have read and write access to the file, and our service starts with the Appsup so:
[Email protected] ~]$ ll/usr/java/default/jre/lib/management/
Total 28
-rw-r--r--. 1 appsup users 3998 Dec jmxremote.access
-RW-------. 1 appsup users 2854 June 11:18 Jmxremote.password
If the permissions are set incorrectly, an error occurs: Error:password file read access must be restricted
-djava.endorsed.dirs
#可以简单理解为 to place the jar file in the directory specified by-djava.endorsed.dirs, there will be functionality to override the system API. Can be forced to understand that the modified API into the virtual machine specified by the launch API, instead. However, classes that can be overridden are limited, and do not include classes in the Java.lang package
-classpath
#参数为目录下所有jar文件
-dsun.rmi.dgc.client.gcinterval=3600000
-dsun.rmi.dgc.server.gcinterval=3600000
#指定rmi调用时gc的时间间隔
#rmi是Java远程方法调用, the Java RMI (Java Remote Method invocation), is an application programming interface for implementing remote procedure calls in the Java programming language. It enables programs that are running on the client computer to invoke objects on the remote server. The Remote method invocation feature enables Java programmers to distribute operations in a network environment. The whole purpose of RMI is to simplify the use of remote interface objects as much as possible.
-djava.awt.headless=true
#Headless模式是系统的一种配置模式. In this mode, the system is missing a display device, keyboard, or mouse.
-dsun.lang.classloader.allowarraysyntax=true
# (This was needed to workaround for the bug 6434149 for JAVA 1.6) as it won ' t work without it.
#原来jdk5 don't report this error at 0. java.lang.ClassNotFoundException: [ Ljava.lang.String, this error occurs with jdk6.0, because there is no overload java.lang.String this class
-doracle.net.tns_admin
#设置JVM的oracle. Net.tns_admin's System Property
The complete definition of TNS in Oracle: Transparence network substrate transparent networks, monitoring service is an important part of it, not all, do not regard TNS as just a listener.
TNS is part of Oracle NET, a tool dedicated to managing and configuring Oracle Database and client connections, and in most cases the client and database must be configured for TNS, but in rare cases, you can connect to an Oracle database without having to configure TNS. For example, through JDBC. If you connect to Oracle through TNS, the client must install the Oracle clients program.
Oracle, if you want to access a server, you must set up TNS, it does not like SQL Server in the client automatically enumerate all the online servers in the LAN, simply select the required server on the client, and then use the account and password to log in. Oracle does not automatically enumerate the servers in the network and needs to read the TNS configuration file to list the configured server names.
The profile name is typically: Tnsnames.ora, default path:%oracle_home%\network\admin\tnsnames.ora
-java.net.preferipv4stack (Default:false)
#If IPv6 is available on the operating system the underlying native socket
Would be a IPv6 socket. This allows Java (tm) applications to connect too, and
Accept connections from, both IPV4 and IPV6 hosts.
If an application have a preference to only use IPV4 sockets then this
Property can is set to true. The implication is and the application would not be
Able to communicate with IPV6 hosts.
-djboss.platform.mbeanserver
To have JBoss EAP use the JDK's Mbean server
An mbean is typically a Java class that provides an interface that enables the class to have administrative functions (such as standard Mbean, which are defined in the interface to enable the MBean to have management capabilities).
Mbeanserver is a Java class that manages the Mbean, you need to register an Mbean with the Mbean server, the Mbean will have administrative functions, the Mbean server also provides the function of querying and registering listeners, Sun provides just the interface, The Mbean server implementations in different JMX implementations are also different.
Mbeanserver is a repository that contains all the registered Mbean. It is the core of the JMX agent layer. The JMX1.0 specification provides an interface called Javax.management.MBeanServer. All managed in Mbean operations are performed via Mbeanserver. With Mbeanserver instances, you can manage all mbean. Each mbean has a unique flag called objectname.
-djavax.management.builder.initial=org.jboss.system.server.jmx.mbeanserverbuilderimpl
In the case of JBoss 4.x, add-djboss.platform.mbeanserver to the JVM startup parameters. For JBoss EAP 5.x, because it is based on the JBoss as 5.1, also need this parameter-djavax.management.builder.initial=org.jboss.system.server.jmx.mbeanserverbuilderimpl otherwise start to report a bunch of exceptions.
-javaagent:/opt/appoptics/appoptics-agent.jar
#会在main方法之前预先执行premain方法
The Agent class must be hit into a jar package, and then inside the meta-inf/mainifest. MF must contain premain-class this property
-dorg.jboss.resolver.warning=true
This option warns the When a XML entity is defined as the SYSTEM with protocol are not "file://" or "vfsfile://", which are most Li Kely something not expected.
-org.jboss.main
Parameter Org.jboss.Main in #run. sh
-xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n
-xrunjdwp
#This option loads the JPDA reference implementation of JDWP. This library resides in the target VMS and uses JVMDI and JNI to interact with it. It uses a transport and the JDWP protocol to communicate with a separate debugger application.
Dt_socket: the means of communication used
Server: Whether you are actively connecting to the debugger or waiting for the debugger to connect as a server
Suspend: Whether to pause when the JVM is started and wait for the debugger to connect
Address: Addresses and ports, addresses can be omitted, and both are separated by colons
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
#JVM 1.5 version should be used similar to the above command (old or can be used), is a agentlib on the line, the following parameters have not changed
-djboss.modules.system.pkgs=org.jboss.byteman
#This complicates matters for integration and other javaagents which alter the script because this property must also be Set and it is not a defined in the JVM, what precedence is given to multiple same property settings on the command line.
-djboss.modules.policy-permissions=true
#The Java Security Manager must is enabled for the JBoss application server.
-jaxpmodule Javax.xml.jaxp-provider Org.jboss.as.standalone
#JAXP (Java API for xmlprocessing, the Java API for XML processing) is one of the application interfaces of Java XML programming that provides the ability to parse and validate XML documents.
-djruby.native.enabled=false
#关闭Ruby
-djava.library.path=/bin/native
#指定非java类包的位置 (eg: dll,so)

Java startup parameters in a detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.