JVM optimization involves two major aspects of my personal understanding1How to allocate the JVM's memory space2. What should I use garbage collector? The garbage generated by the JVM needs to be recycled, recycled, and the JVM's tuning needs to understand the rationale and ultimate goal of each garbage collection mechanism: reducing the frequency of full GC occurrences (full GC appears that causes the app to pause the service) to optimize the catalina.sh configuration file. Add the following code in the catalina.sh configuration file: Java_opts="-djava.awt.headless=true-dfile.encoding=utf-8-server-xms1024m-xmx1024m-xx:newsize=512m-xx:maxnewsize=512m- xx:permsize=512m-xx:maxpermsize=512m"server: Be sure to act as the first parameter with good performance on multiple CPUs-Xms: Initial heap memory heap size, minimum memory used, high CPU performance This value should be set to a larger-Xmx: Initial heap memory heap maximum, maximum memory used the top two values are the minimum and maximum memory allocated for the JVM, depending on the size of the hardware physical memory, and are recommended to be half the physical memory. -xx:permsize: Setting a permanent storage area for memory-Xx:maxpermsize: Set a permanent storage area for maximum memory-xx:maxnewsize:-xss15120This causes JBoss to consume 15M of memory as soon as each additional thread is added (thread), and the best value should be 128K, and the default value appears to be 512k.+Xx:aggressiveheap will make XMS meaningless. This parameter allows the JVM to ignore the XMX parameter, frantically eating a g of physical memory, and then eating a G swap. -XSS: Stack size per thread-VERBOSE:GC Reality garbage collection Information-Xloggc:gc.log specifying garbage collection log Files-the heap size of the Xmn:young generation, typically set to one of the 3, 4 points of Xmx-xx:+USEPARNEWGC: Shortening the time of minor collection-XX:+USECONCMARKSWEEPGC: Shortening the time of major collection
Using Jconsole.exe to monitor the JVM
Configuration file Changes
[Email protected] tomcat]$ vim bin/catalina.sh catalina_opts="$CATALINA _opts- Dcom.sun.management.jmxremote # #启用远程监控JMX-dcom.sun.management.jmxremote.port=12345 #jmx远程端口, Zabbix must be added consistently -dcom.sun.management.jmxremote.authenticate=false #不开启用户密码认证- Dcom.sun.management.jmxremote.ssl=false -djava.rmi.server.hostname=192.168. 230.130 " #运行tomcat服务IP (do not fill in the wrong)
Jconsole is an executable file in the Java root directory under the bin file; Click JConsole.exe under Bin file to run the program
Java Enterprise Application Tomcat Combat (iii)