首先我们明白几个概念:
pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<groupId>com.xiyougroupId>
<artifactId>test-tomcatartifactId>
<version>0.0.1-SNAPSHOTversion>
<packaging>warpackaging>
<dependencies>
<dependency>
<groupId>javax.servletgroupId>
<artifactId>javax.servlet-apiartifactId>
<version>3.1.0version>
<scope>providedscope>
dependency>
dependencies>
project>
IndexServlet:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/index")
public class IndexServet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("do get.......");
}
}
此时访问路径:
http://localhost:8080/test-tomcat/index
浏览器正常打印
do get.......
do get.......
此时我们已经搭建web工程成功。
(1)设置当前web工程的虚拟机参数。
(2)添加JVM参数
// 最大堆内存和初始堆内存大小是32M
-XX:+PrintGCDetails -Xmx32M -Xms32M
-XX:+HeapDumpOnOutOfMemoryError
// 串行回收
-XX:+UseSerialGC
// JVM初始分配的非堆内存
-XX:PermSize=32M
(3)运行结果
[GC (Allocation Failure) [DefNew: 8704K->1088K(9792K), 0.0042092 secs] 8704K->2349K(31680K), 0.0042465 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9792K->1087K(9792K), 0.0046263 secs] 11053K->4234K(31680K), 0.0046510 secs] [Times: user=0.03 sys=0.00, real=0.01 secs]
四月 17, 2019 9:48:20 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:test-tomcat' did not find a matching property.
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/7.0.65
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Oct 9 2015 08:36:58 UTC
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.65.0
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: D:\java\jdk1.8\jdk\jre
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_131-b11
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\ecilpse_java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\java\tomcat7.0\apache-tomcat-7.0
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\ecilpse_java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\java\tomcat7.0\apache-tomcat-7.0
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\ecilpse_java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\java\tomcat7.0\apache-tomcat-7.0\endorsed
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -XX:+PrintGCDetails
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Xmx32M
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Xms32M
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -XX:+HeapDumpOnOutOfMemoryError
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -XX:+UseSerialGC
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -XX:PermSize=32M
四月 17, 2019 9:48:20 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
四月 17, 2019 9:48:20 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.
四月 17, 2019 9:48:20 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
四月 17, 2019 9:48:21 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1m 19 Mar 2015)
四月 17, 2019 9:48:21 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-8080"]
[GC (Allocation Failure) [DefNew: 9791K->1088K(9792K), 0.0047578 secs] 12938K->6155K(31680K), 0.0047787 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
四月 17, 2019 9:48:21 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
四月 17, 2019 9:48:21 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 842 ms
四月 17, 2019 9:48:21 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
四月 17, 2019 9:48:21 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.65
[GC (Allocation Failure) [DefNew: 9792K->1088K(9792K), 0.0044290 secs] 14859K->7657K(31680K), 0.0044492 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[GC (Allocation Failure) [DefNew: 9792K->1070K(9792K), 0.0030075 secs] 16361K->8502K(31680K), 0.0030274 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9774K->197K(9792K), 0.0015286 secs] 17206K->7851K(31680K), 0.0015501 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 8901K->518K(9792K), 0.0016342 secs] 16555K->8172K(31680K), 0.0016544 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9222K->602K(9792K), 0.0014834 secs] 16875K->8256K(31680K), 0.0015026 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9306K->670K(9792K), 0.0019575 secs] 16960K->8436K(31680K), 0.0019845 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9374K->637K(9792K), 0.0017063 secs] 17140K->8539K(31680K), 0.0017339 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9341K->636K(9792K), 0.0017471 secs] 17243K->8722K(31680K), 0.0017660 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9340K->549K(9792K), 0.0016938 secs] 17426K->8841K(31680K), 0.0017128 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9253K->604K(9792K), 0.0016553 secs] 17545K->9039K(31680K), 0.0016727 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9308K->652K(9792K), 0.0017343 secs] 17743K->9239K(31680K), 0.0017532 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9356K->624K(9792K), 0.0018626 secs] 17943K->9365K(31680K), 0.0018825 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9328K->505K(9792K), 0.0017484 secs] 18069K->9438K(31680K), 0.0017727 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9209K->713K(9792K), 0.0017808 secs] 18142K->9645K(31680K), 0.0018016 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9417K->505K(9792K), 0.0020207 secs] 18349K->9781K(31680K), 0.0020406 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9209K->605K(9792K), 0.0015793 secs] 18485K->9880K(31680K), 0.0015982 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9309K->668K(9792K), 0.0018061 secs] 18584K->10044K(31680K), 0.0018295 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9372K->745K(9792K), 0.0017907 secs] 18748K->10274K(31680K), 0.0018112 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9449K->634K(9792K), 0.0021561 secs] 18978K->10439K(31680K), 0.0021766 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9338K->597K(9792K), 0.0017612 secs] 19143K->10574K(31680K), 0.0017801 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9301K->597K(9792K), 0.0017708 secs] 19278K->10780K(31680K), 0.0017878 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9301K->592K(9792K), 0.0017464 secs] 19484K->10929K(31680K), 0.0017644 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9294K->580K(9792K), 0.0017054 secs] 19630K->11073K(31680K), 0.0017250 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9284K->522K(9792K), 0.0016996 secs] 19777K->11192K(31680K), 0.0017189 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9226K->670K(9792K), 0.0029796 secs] 19896K->11340K(31680K), 0.0030178 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9374K->704K(9792K), 0.0019694 secs] 20044K->11530K(31680K), 0.0019896 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9408K->551K(9792K), 0.0025404 secs] 20234K->11675K(31680K), 0.0025632 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9255K->601K(9792K), 0.0018411 secs] 20379K->11860K(31680K), 0.0018639 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9305K->561K(9792K), 0.0019566 secs] 20564K->11988K(31680K), 0.0019758 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9263K->559K(9792K), 0.0018549 secs] 20690K->12140K(31680K), 0.0018754 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9263K->559K(9792K), 0.0021693 secs] 20844K->12305K(31680K), 0.0021901 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9263K->547K(9792K), 0.0018555 secs] 21009K->12440K(31680K), 0.0018744 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9251K->661K(9792K), 0.0025687 secs] 21144K->12714K(31680K), 0.0025905 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9365K->704K(9792K), 0.0019168 secs] 21418K->12912K(31680K), 0.0019357 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9408K->404K(9792K), 0.0020015 secs] 21616K->13048K(31680K), 0.0020217 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9108K->572K(9792K), 0.0017464 secs] 21752K->13216K(31680K), 0.0017667 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9276K->540K(9792K), 0.0019178 secs] 21920K->13340K(31680K), 0.0019437 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9244K->658K(9792K), 0.0017837 secs] 22044K->13458K(31680K), 0.0018119 secs] [Times: user=0.06 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9362K->619K(9792K), 0.0021802 secs] 22162K->13589K(31680K), 0.0022087 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9323K->647K(9792K), 0.0022363 secs] 22293K->13756K(31680K), 0.0022568 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9351K->680K(9792K), 0.0020778 secs] 22460K->13931K(31680K), 0.0020977 secs] [Times: user=0.05 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9384K->537K(9792K), 0.0022819 secs] 22635K->14062K(31680K), 0.0023165 secs] [Times: user=0.05 sys=0.01, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9241K->671K(9792K), 0.0026027 secs] 22766K->14195K(31680K), 0.0026389 secs] [Times: user=0.06 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9375K->667K(9792K), 0.0024397 secs] 22899K->14331K(31680K), 0.0024641 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9371K->627K(9792K), 0.0019550 secs] 23035K->14446K(31680K), 0.0019745 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9331K->584K(9792K), 0.0030877 secs] 23150K->14545K(31680K), 0.0031269 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9288K->600K(9792K), 0.0020820 secs] 23249K->14710K(31680K), 0.0021083 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9304K->537K(9792K), 0.0019219 secs] 23414K->14788K(31680K), 0.0019489 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9241K->656K(9792K), 0.0017336 secs] 23492K->14907K(31680K), 0.0017532 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9360K->611K(9792K), 0.0018870 secs] 23611K->14989K(31680K), 0.0019117 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9315K->582K(9792K), 0.0018552 secs] 23693K->15079K(31680K), 0.0018732 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9286K->540K(9792K), 0.0019335 secs] 23783K->15175K(31680K), 0.0019521 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9244K->1087K(9792K), 0.0020765 secs] 23879K->15823K(31680K), 0.0020955 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9791K->1K(9792K), 0.0017041 secs] 24527K->15317K(31680K), 0.0017230 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 8705K->312K(9792K), 0.0014080 secs] 24021K->15629K(31680K), 0.0014272 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
四月 17, 2019 9:48:22 下午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
四月 17, 2019 9:48:22 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [122] milliseconds.
[GC (Allocation Failure) [DefNew: 9016K->1063K(9792K), 0.0019935 secs] 24333K->16379K(31680K), 0.0020137 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9767K->299K(9792K), 0.0024439 secs] 25083K->16258K(31680K), 0.0024654 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9003K->500K(9792K), 0.0018052 secs] 24962K->16459K(31680K), 0.0018379 secs] [Times: user=0.06 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9204K->617K(9792K), 0.0016329 secs] 25163K->16576K(31680K), 0.0016508 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9321K->575K(9792K), 0.0020971 secs] 25280K->16688K(31680K), 0.0021189 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9279K->616K(9792K), 0.0019838 secs] 25392K->16905K(31680K), 0.0020082 secs] [Times: user=0.06 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9320K->527K(9792K), 0.0026495 secs] 25609K->16986K(31680K), 0.0026777 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9231K->693K(9792K), 0.0016990 secs] 25690K->17152K(31680K), 0.0017176 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9397K->579K(9792K), 0.0022363 secs] 25856K->17318K(31680K), 0.0022581 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9283K->626K(9792K), 0.0021375 secs] 26022K->17505K(31680K), 0.0021596 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9330K->539K(9792K), 0.0020801 secs] 26209K->17570K(31680K), 0.0021067 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9243K->714K(9792K), 0.0017519 secs] 26274K->17745K(31680K), 0.0017708 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9418K->696K(9792K), 0.0018693 secs] 26449K->17912K(31680K), 0.0018886 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9400K->583K(9792K), 0.0018183 secs] 26616K->17979K(31680K), 0.0018392 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9287K->660K(9792K), 0.0018064 secs] 26683K->18150K(31680K), 0.0018289 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9364K->659K(9792K), 0.0018914 secs] 26854K->18292K(31680K), 0.0019129 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9363K->662K(9792K), 0.0018145 secs] 26996K->18443K(31680K), 0.0018366 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9366K->756K(9792K), 0.0017744 secs] 27147K->18660K(31680K), 0.0017952 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9455K->619K(9792K), 0.0019255 secs] 27360K->18835K(31680K), 0.0019463 secs] [Times: user=0.06 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9323K->635K(9792K), 0.0018003 secs] 27539K->18988K(31680K), 0.0018212 secs] [Times: user=0.06 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9339K->581K(9792K), 0.0022809 secs] 27692K->19152K(31680K), 0.0023066 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9285K->516K(9792K), 0.0022880 secs] 27856K->19262K(31680K), 0.0023178 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9220K->638K(9792K), 0.0016967 secs] 27966K->19384K(31680K), 0.0017176 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9342K->668K(9792K), 0.0020913 secs] 28088K->19567K(31680K), 0.0021134 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9372K->681K(9792K), 0.0018359 secs] 28271K->19731K(31680K), 0.0018558 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9385K->702K(9792K), 0.0019476 secs] 28435K->19890K(31680K), 0.0019691 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9406K->543K(9792K), 0.0021507 secs] 28594K->20022K(31680K), 0.0021725 secs] [Times: user=0.06 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9247K->708K(9792K), 0.0020708 secs] 28726K->20187K(31680K), 0.0020964 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9412K->536K(9792K), 0.0018632 secs] 28891K->20325K(31680K), 0.0018805 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9240K->693K(9792K), 0.0019870 secs] 29029K->20482K(31680K), 0.0020105 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9397K->508K(9792K), 0.0020595 secs] 29186K->20596K(31680K), 0.0020826 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9212K->760K(9792K), 0.0019084 secs] 29300K->20848K(31680K), 0.0019261 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9464K->688K(9792K), 0.0021519 secs] 29552K->21075K(31680K), 0.0021712 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9392K->517K(9792K), 0.0023162 secs] 29779K->21204K(31680K), 0.0023386 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9221K->658K(9792K), 0.0018340 secs] 29908K->21345K(31680K), 0.0018600 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9362K->509K(9792K), 0.0019043 secs] 30049K->21480K(31680K), 0.0019264 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9213K->629K(9792K), 0.0020984 secs] 30184K->21599K(31680K), 0.0021247 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9333K->625K(9792K), 0.0020387 secs] 30303K->21753K(31680K), 0.0020615 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9329K->642K(9792K), 0.0020788 secs] 30457K->21911K(31680K), 0.0020987 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9346K->685K(9792K), 0.0024609 secs] 30615K->22082K(31680K), 0.0024888 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9389K->496K(9792K), 0.0024782 secs] 30786K->22180K(31680K), 0.0025048 secs] [Times: user=0.03 sys=0.02, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9200K->9200K(9792K), 0.0000109 secs][Tenured: 21683K->14344K(21888K), 0.0273326 secs] 30884K->14344K(31680K), [Metaspace: 14208K->14208K(1062912K)], 0.0273916 secs] [Times: user=0.09 sys=0.00, real=0.03 secs]
[GC (Allocation Failure) [DefNew: 8704K->221K(9792K), 0.0012688 secs] 23048K->14565K(31680K), 0.0012899 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 8925K->351K(9792K), 0.0013512 secs] 23269K->14695K(31680K), 0.0013711 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9055K->456K(9792K), 0.0011924 secs] 23399K->14800K(31680K), 0.0012107 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9160K->598K(9792K), 0.0014122 secs] 23504K->14942K(31680K), 0.0014327 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9302K->534K(9792K), 0.0015556 secs] 23646K->15028K(31680K), 0.0015783 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9238K->654K(9792K), 0.0017724 secs] 23732K->15149K(31680K), 0.0018048 secs] [Times: user=0.03 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9358K->610K(9792K), 0.0014988 secs] 23853K->15228K(31680K), 0.0015251 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9314K->585K(9792K), 0.0016043 secs] 23932K->15323K(31680K), 0.0016258 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9289K->562K(9792K), 0.0014301 secs] 24027K->15431K(31680K), 0.0014491 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9266K->1087K(9792K), 0.0017038 secs] 24135K->16075K(31680K), 0.0017246 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9791K->649K(9792K), 0.0015652 secs] 24779K->16131K(31680K), 0.0015841 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9353K->420K(9792K), 0.0010131 secs] 24835K->15976K(31680K), 0.0010317 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9124K->385K(9792K), 0.0006997 secs] 24680K->15941K(31680K), 0.0007186 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 9089K->404K(9792K), 0.0008405 secs] 24645K->15961K(31680K), 0.0008585 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
四月 17, 2019 9:48:23 下午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
四月 17, 2019 9:48:23 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-8080"]
四月 17, 2019 9:48:23 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
四月 17, 2019 9:48:23 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 2205 ms
[GC (Allocation Failure) [DefNew: 9086K->1087K(9792K), 0.0030781 secs] 24642K->20143K(31680K), 0.0030993 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
根据上面的结果可以看到其垃圾回收次数。
我们分别对其进行最大堆内存的扩大和初始堆内存扩大
-XX:+PrintGCDetails -Xmx512M –Xms32M
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseSerialGC
-XX:PermSize=32M
-XX:+PrintGCDetails -Xmx512M –Xms512M
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseSerialGC
-XX:PermSize=32M
结果这里不再给出,直接说结论:(针对串行回收)
(1)最大内存越大,吞吐量就越高
(2)进一步优化是最大内存和初始内存相等,且最大堆内存大,其吞吐量高,且垃圾回收次数少
垃圾回收的次数和初始堆内存有关系,初始堆内存越小,GC的回收次数越多。最好是将初始堆内存大小和最大堆内存大小相等。
-XX:+PrintGCDetails -Xmx512M –Xms512M
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseParNewGC
-XX:PermSize=32M
结论和串行回收一致,但是并行回收的效率高于同等条件下的串行回收
(2)并行合并回收
-XX:+PrintGCDetails -Xmx512M -Xms256M
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseParallelGC
-XX:+UseParallelOldGC
-XX:ParallelGCThreads=8
-XX:PermSize=32M
表示新生代和老年代都进行回收(Parallel和ParallelOld),推荐这种方式,该方式的吞吐量最高,且垃圾收集器次数最少、
Tomcat的调优和JVM的调优核心是一致的
(1)初始堆值和最大堆内存一致,就是说初始堆内存越大,垃圾回收次数越少
(2)最大堆内存越大,吞吐量就越高
(3)设置堆内存的新生代和老年代的比例最好是1:2或者1:3
(4)减少GC对老年代的回收。