Tomcat 8 JVM Heap 메모리 늘리기
java는 메모리 관리를 자동으로 하지만, 기본적으로 Heap메모리를 잡아두면, 많은 메모리 사용에서 유용하게 설정을 할 수 있습니다.
윈도우의 경우, Catalina.bat에서 setenv.bat파일이 있는지 확인하고, 있으면 해당 파일을 실행합니다.
(참고 catalina.bat) |
rem Get standard environment variables
if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome
call "%CATALINA_BASE%\bin\setenv.bat" |
[경로]
{톰캣위치}/bin/setenv.bat 파일 생성해서, Tomcat 의 JVM Heap 메모리 늘려줍니다.
setenv.bat |
set "JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx8192m -XX:MaxPermSize=256m -server" |
참고: https://crunchify.com/how-to-change-jvm-heap-setting-xms-xmx-of-tomcat/
Tomcat 윈도우에서 Service로 등록하기
Installing services
The safest way to manually install the service is to use the provided service.bat script. Administrator privileges are required to run this script. If necessary, you can use the /user
switch to specify a user to use for the installation of the service.
NOTE: On Windows Vista or any later operating system with User Account Control (UAC) enabled you will be asked for additional privileges when 'Tomcat8.exe' is launched by the script.
If you want to pass additional options to service installer as PR_*
environment variables, you have to either configure them globally in OS, or launch the program that sets them with elevated privileges (e.g. right-click on cmd.exe and select "Run as administrator"; on Windows 8 (or later) or Windows Server 2012 (or later), you can open an elevated command prompt for the current directory from the Explorer by clicking on the "File" menu bar). See issue 56143for details.
Install the service named 'Tomcat8'
C:\> service.bat install
There is a 2nd optional parameter that lets you specify the name of the service, as displayed in Windows services.
Install the service named 'MyService'
C:\> service.bat install MyService
If using tomcat8.exe, you need to use the //IS// parameter.
Install the service named 'Tomcat8'
C:\> tomcat8 //IS//Tomcat8 --DisplayName="Apache Tomcat 8" ^
--Install="C:\Program Files\Tomcat\bin\tomcat8.exe" --Jvm=auto ^
--StartMode=jvm --StopMode=jvm ^
--StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start ^
--StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop
Updating services
To update the service parameters, you need to use the //US// parameter.
Update the service named 'Tomcat8'
C:\> tomcat8 //US//Tomcat8 --Description="Apache Tomcat Server - https://tomcat.apache.org/ " ^
--Startup=auto --Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar
If you gave the service an optional name, you need to specify it like this:
Update the service named 'MyService'
C:\> tomcat8 //US//MyService --Description="Apache Tomcat Server - https://tomcat.apache.org/ " ^
--Startup=auto --Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar
Removing services
To remove the service, you need to use the //DS// parameter.
If the service is running it will be stopped and then deleted.
Remove the service named 'Tomcat8'
C:\> tomcat8 //DS//Tomcat8
If you gave the service an optional name, you need to specify it like this:
Remove the service named 'MyService'
C:\> tomcat8 //DS//MyService
출처: https://tomcat.apache.org/tomcat-8.0-doc/windows-service-howto.html