Spring Boot 1.4.x ã® Web ã¢ããªã 1.5.x ã¸ãã¼ã¸ã§ã³ã¢ãããã ( ãã®ï¼ï¼ )( -XX:+ExitOnOutOfMemoryError 㨠-XX:+CrashOnOutOfMemoryError ãªãã·ã§ã³ã®ã©ã¡ããæå®ãã¹ããï¼ )
æ¦è¦
è¨äºä¸è¦§ã¯ãã¡ãã§ãã
- ä»åã®æé ã§ç¢ºèªã§ããã®ã¯ä»¥ä¸ã®å
容ã§ãã
- stackoverflow ã® Java - shutting down on Out of Memory Error ã® QA 㧠8u92 ãã
-XX:+ExitOnOutOfMemoryError
ã¨-XX:+CrashOnOutOfMemoryError
ã®ãªãã·ã§ã³ã追å ã«ãªã£ãã¨è¦ããã¦ãããããã°ã©ã¡ããæå®ãã¦ããªãã£ããã¨ã«æ°ã¥ãã¾ããã - ãã ããã»ã¨ãã©ä¼¼ããããªãªãã·ã§ã³ã«è¦ãã¦ã©ã¡ããæå®ããæ¹ãããã®ãããåãããªãã£ãã®ã§ããã®èª¿æ»ããã¾ãã
- stackoverflow ã® Java - shutting down on Out of Memory Error ã® QA 㧠8u92 ãã
åç §ãããµã¤ãã»æ¸ç±
-
Java - shutting down on Out of Memory Error
https://stackoverflow.com/questions/12096403/java-shutting-down-on-out-of-memory-error Print All JVM Flags
https://stackoverflow.com/questions/10486375/print-all-jvm-flagsImplement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
https://bugs.openjdk.java.net/browse/JDK-8138745Release Note: New JVM Options: ExitOnOutOfMemoryError and CrashOnOutOfMemoryError
https://bugs.openjdk.java.net/browse/JDK-81526698u92 Update Release Notes
http://www.oracle.com/technetwork/java/javase/8u92-relnotes-2949471.htmlterazzoã®æ¥è¨ - Javaã§OutOfMemoryErrorãåºãæ¹æ³
http://d.hatena.ne.jp/terazzo/20130320/1363731368
ç®æ¬¡
- 確èªã®åã« -XX:HeapDumpPath, -XX:ErrorFile ã§æå®ãããã¡ã¤ã«åã«æ¥æãä»ãããã«ãã
- -XX:+ExitOnOutOfMemoryError 㨠-XX:+CrashOnOutOfMemoryError ã®ãªãã·ã§ã³ã追å ããã¦ãããã¨ã確èªãã
- å®éã« OutOfMemory ãçºçããå¦çã追å ãã¦ç¸éç¹ã確èªãã
- ã¾ã¨ã
- webapp_startup.bat ãä¿®æ£ãã
æé
確èªã®åã« -XX:HeapDumpPath, -XX:ErrorFile ã§æå®ãããã¡ã¤ã«åã«æ¥æãä»ãããã«ãã
/webapps/ksbysample-webapp-lending/bat/webapp_startup.bat ã¯ç¾å¨ä»¥ä¸ã®å 容ã§ããã
@echo on setlocal set JAVA_HOME=C:\Java\jdk1.8.0_131 set PATH=%JAVA_HOME%\bin;%PATH% set WEBAPP_HOME=C:\webapps\ksbysample-webapp-lending set WEBAPP_JAR=ksbysample-webapp-lending-1.5.4-RELEASE.jar cd /d %WEBAPP_HOME% java -server ^ -Xms1024m -Xmx1024m ^ -XX:MaxMetaspaceSize=384m ^ -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled ^ -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 ^ -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark ^ -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps ^ -Xloggc:%WEBAPP_HOME%/logs/gc.log ^ -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=10M ^ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%WEBAPP_HOME%/logs/%date:~0,4%%date:~5,2%%date:~8,2%.hprof ^ -XX:ErrorFile=%WEBAPP_HOME%/logs/hs_err_pid_%p.log ^ -Dsun.net.inetaddr.ttl=100 ^ -Dcom.sun.management.jmxremote ^ -Dcom.sun.management.jmxremote.port=7900 ^ -Dcom.sun.management.jmxremote.ssl=false ^ -Dcom.sun.management.jmxremote.authenticate=false ^ -Dspring.profiles.active=product ^ -jar lib\%WEBAPP_JAR%
以ä¸ã®åé¡ããããã¨ã«æ°ã¥ãã¾ããã
-XX:HeapDumpPath=%WEBAPP_HOME%/logs/%date:~0,4%%date:~5,2%%date:~8,2%.hprof
ã ã¨ãã¡ã¤ã«ã«æ¥ä»ããä»ãããåãæ¥ã« HeapDump ãåºåãããå ´åã«åã®ãã¡ã¤ã«ãä¸æ¸ãããã¦ãã¾ãã-XX:ErrorFile=%WEBAPP_HOME%/logs/hs_err_pid_%p.log
ã® %p ã§ããã»ã¹ ID ãä»ããã®ã¨æã£ã¦ãã¾ããããWindows ã ãããªã®ãããã»ã¹ ID ã§ã¯ãªããã ã® “p” ã«ãªã£ã¦ãã¾ãã
ã©ã¡ãããã¡ã¤ã«åã«æ¥æãä»ãããã«ä»¥ä¸ã®ããã«å¤æ´ãã¾ãããã®ä¿®æ£ã¯ãã¡ã¤ã«çææã«æ¥æãä»ãããã®ã§ã¯ãªããæçµçã«ã¯ -XX:+CrashOnOutOfMemoryError
ãªãã·ã§ã³ãä»ãã¦ãjava ã³ãã³ããçµäºããå¾ã«æ¥æã®ä»ãããã¡ã¤ã«åã« rename ããæ³å®ã®ãã®ã§ãã
@echo on setlocal set JAVA_HOME=C:\Java\jdk1.8.0_131 set PATH=%JAVA_HOME%\bin;%PATH% set WEBAPP_HOME=C:\webapps\ksbysample-webapp-lending set WEBAPP_JAR=ksbysample-webapp-lending-1.5.4-RELEASE.jar set LOGS_DIR=%WEBAPP_HOME%\logs set PATH_HEAPDUMPFILE=%LOGS_DIR%\heapdump.hprof set PATH_ERRORFILE=%LOGS_DIR%\hs_err.log cd /d %WEBAPP_HOME% java -server ^ -Xms1024m -Xmx1024m ^ -XX:MaxMetaspaceSize=384m ^ -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled ^ -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 ^ -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark ^ -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps ^ -Xloggc:%WEBAPP_HOME%/logs/gc.log ^ -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=10M ^ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%PATH_HEAPDUMPFILE% ^ -XX:ErrorFile=%PATH_ERRORFILE% ^ -Dsun.net.inetaddr.ttl=100 ^ -Dcom.sun.management.jmxremote ^ -Dcom.sun.management.jmxremote.port=7900 ^ -Dcom.sun.management.jmxremote.ssl=false ^ -Dcom.sun.management.jmxremote.authenticate=false ^ -Dspring.profiles.active=product ^ -jar lib\%WEBAPP_JAR% set YYYYMMDD=%date:~0,4%%date:~5,2%%date:~8,2% set HHMMSS=%time:~0,8% set HHMMSS=%HHMMSS::=% set HHMMSS=%HHMMSS: =% if exist %PATH_HEAPDUMPFILE% rename %PATH_HEAPDUMPFILE% heapdump_%YYYYMMDD%%HHMMSS%.hprof if exist %PATH_ERRORFILE% rename %PATH_ERRORFILE% hs_err_%YYYYMMDD%%HHMMSS%.log
-XX:+ExitOnOutOfMemoryError 㨠-XX:+CrashOnOutOfMemoryError ã®ãªãã·ã§ã³ã追å ããã¦ãããã¨ã確èªãã
ãªãã·ã§ã³ã追å ãããã®ã¯åãã£ãã®ã§ãããå®éã« java.exe ãå®è¡ããçãã¦ãªãã·ã§ã³ã確èªããæ¹æ³ãããã®ãæ°ã«ãªã£ãã®ã§èª¿ã¹ã¦è¦ã¾ãããPrint All JVM Flags ãè¦ã㨠java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal
ãå®è¡ããã°è¡¨ç¤ºãããããã§ãã
8u131 ã§å®è¡ããã¨ä»¥ä¸ã®è¡ãåºåããã¾ããã
bool CrashOnOutOfMemoryError = false {product} bool ExitOnOutOfMemoryError = false {product}
å®éã« OutOfMemory ãçºçããå¦çã追å ãã¦ç¸éç¹ã確èªãã
OutOfMemory ãçºçããå¦çã追å ãã
src/main/java/ksbysample/webapp/lending/SampleController.java ã以ä¸ã®ããã«å¤æ´ãã¾ãã-Xmx1024m
㨠Java ãã¼ãã®æ大ãµã¤ãºã 1024m ã§æå®ãã¦ããã®ã§ã1024m ã® String ãçæãããã¨ããã° OutOfMemory ã«ãªãã¯ãã§ãã
@Controller @RequestMapping("/sample") public class SampleController { .......... @RequestMapping("/outofmemory") @ResponseBody public void outofmemory() { String msg = StringUtils.repeat('x', 1024 * 1024 * 1024); } }
clean ã¿ã¹ã¯å®è¡ â Rebuild Project å®è¡ â build ã¿ã¹ã¯ãå®è¡ã㦠ksbysample-webapp-lending-1.5.4-RELEASE.jar ãçæããå¾ãC:\webapps\ksbysample-webapp-lending\lib ã®ä¸ã¸ã³ãã¼ãã¾ãã
ã©ã¡ãã®ãªãã·ã§ã³ãæå®ãã¦ããªãå ´åãã©ããªãã®ãï¼
webapp_startup.bat ãå®è¡ã㦠Tomcat ãèµ·åããå¾ãhttp://localhost:8080/sample/outofmemory ã«ã¢ã¯ã»ã¹ãã㨠OutOfMemoryError ãçºçãã¾ãã
ãã°ãã¡ã¤ã« ksbysample-webapp-lending.log ã«ã¯ at ksbysample.webapp.lending.SampleController.outofmemory(SampleController.java:31)
ãåºåããã¦ãããOutOfMemoryError ãçºçããåå ã®ç®æãåããã¾ãã
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:982) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:150) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:167) at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.OutOfMemoryError: Java heap space at org.apache.commons.lang3.StringUtils.repeat(StringUtils.java:6087) at ksbysample.webapp.lending.SampleController.outofmemory(SampleController.java:31) at ksbysample.webapp.lending.SampleController$$FastClassBySpringCGLIB$$709005bd.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) at ksbysample.webapp.lending.aspect.logging.RequestAndResponseLogger.logginRequestAndResponse(RequestAndResponseLogger.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) at ksbysample.webapp.lending.SampleController$$EnhancerBySpringCGLIB$$a1afe1d0.outofmemory(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
ã³ã³ã½ã¼ã«ã«ã¯ Heap dump file created
ã®ãã°ãåºåãããã ãã§ãWeb ã¢ããªã±ã¼ã·ã§ã³ã¯çµäºãã¾ããã
C:\webapps\ksbysample-webapp-lending\logs ã®ä¸ã«ã¯ heapdump.hprof ãä½æããã¦ãã¾ãã
ã³ã³ã½ã¼ã«ã§ Ctrl+C ãæ¼ã㦠Tomcat ãåæ¢ãã¾ãã
-XX:+ExitOnOutOfMemoryError
ãªãã·ã§ã³ãæå®ããã¨ã©ããªããï¼
webapp_startup.bat ã以ä¸ã®ããã«å¤æ´ãã¾ãã
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%WEBAPP_HOME%/logs/%date:~0,4%%date:~5,2%%date:~8,2%.hprof ^
ãªãã·ã§ã³ãåé¤ãã¾ãã-XX:+ExitOnOutOfMemoryError
ã追å ãã¾ãã
-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=10M ^ -XX:+ExitOnOutOfMemoryError ^ -XX:ErrorFile=%PATH_ERRORFILE% ^
webapp_startup.bat ãå®è¡ã㦠Tomcat ãèµ·åããå¾ãhttp://localhost:8080/sample/outofmemory ã«ã¢ã¯ã»ã¹ã㦠OutOfMemoryError ãçºçããã¾ãã
ãã°ãã¡ã¤ã« ksbysample-webapp-lending.log ã«ã¯ä½ãåºåããã¾ããã§ããã
ã³ã³ã½ã¼ã«ã«ã¯ Terminating due to java.lang.OutOfMemoryError: Java heap space
ã¨åºåãã㦠Web ã¢ããªã±ã¼ã·ã§ã³ã¯çµäºãã¦ãã¾ãã
C:\webapps\ksbysample-webapp-lending\logs ã®ä¸ã«ã¯ä½ãä½æããã¾ããã
-XX:+CrashOnOutOfMemoryError
ãªãã·ã§ã³ãæå®ããã¨ã©ããªããï¼
webapp_startup.bat ã以ä¸ã®ããã«å¤æ´ãã¾ãã
-XX:+ExitOnOutOfMemoryError
ãåé¤ãã¦ã-XX:+CrashOnOutOfMemoryError
ã追å ãã¾ãã
-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=10M ^ -XX:+CrashOnOutOfMemoryError ^ -XX:ErrorFile=%PATH_ERRORFILE% ^
webapp_startup.bat ãå®è¡ã㦠Tomcat ãèµ·åããå¾ãhttp://localhost:8080/sample/outofmemory ã«ã¢ã¯ã»ã¹ã㦠OutOfMemoryError ãçºçããã¾ãã
-XX:+ExitOnOutOfMemoryError
ãªãã·ã§ã³ã®æã¨åãããã°ãã¡ã¤ã« ksbysample-webapp-lending.log ã«ã¯ä½ãåºåããã¾ããã
ã³ã³ã½ã¼ã«ã«ã¯ Aborting due to java.lang.OutOfMemoryError: Java heap space
ã¨åºåãã㦠Web ã¢ããªã±ã¼ã·ã§ã³ã¯çµäºãã¦ãã¾ãã
C:\webapps\ksbysample-webapp-lending\logs ã®ä¸ã«ã¯ hs_err_20170717155857.log ã¨ãããã¡ã¤ã«ãä½æããã¦ã
hs_err_20170717155857.log ãéãã¨ä»¥ä¸ã®ãããªãã°ãåºåããã¦ãã¾ãããã®ãã°ãã¡ã¤ã«ã ã¨ã¯ã©ã¹ã¨ã¡ã½ããã¯åããã¾ãããè¡æ°ã¾ã§ã¯åããã¾ããã
# # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (debug.cpp:308), pid=10920, tid=0x0000000000002d64 # fatal error: OutOfMemory encountered: Java heap space # # JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode windows-amd64 compressed oops) # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # --------------- T H R E A D --------------- Current thread (0x000000005f7b4000): JavaThread "http-nio-8080-exec-1" daemon [_thread_in_vm, id=11620, stack(0x0000000065f00000,0x0000000066000000)] Stack: [0x0000000065f00000,0x0000000066000000] [error occurred during error reporting (printing stack bounds), id 0xc0000005] Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j org.apache.commons.lang3.StringUtils.repeat(CI)Ljava/lang/String;+8 j ksbysample.webapp.lending.SampleController.outofmemory()V+4 ..........
ã¾ã¨ã
-XX:+ExitOnOutOfMemoryError
ãªãã·ã§ã³ãæå®ããã¨ä½ããã°ãåºåããã« Web ã¢ããªã±ã¼ã·ã§ã³ãçµäºãã¾ãã-XX:+CrashOnOutOfMemoryError
ãªãã·ã§ã³ãæå®ããã¨-XX:ErrorFile
ãªãã·ã§ã³ã§æå®ããããã¡ã¤ã«ã«ã¨ã©ã¼ãã¡ã¤ã«ãçæãã㦠Web ã¢ããªã±ã¼ã·ã§ã³ãçµäºãã¾ãã-XX:ErrorFile
ãªãã·ã§ã³ãæå®ãã¦ããªãå ´åã«ã¯ããã©ã«ãã®è¨å®å ´æï¼ksbysample-webapp-lending ã®å ´å㯠C:\webapps\ksbysample-webapp-lending ã§ããï¼ã«çæããã¾ãããã®ãã¡ã¤ã«ãè¦ã㨠OutOfMemory ãçºçããã¯ã©ã¹ã¨ã¡ã½ããã¯åããã¾ãããè¡æ°ã¾ã§ã¯åããã¾ããã-XX:+ExitOnOutOfMemoryError
ãããã¯-XX:+CrashOnOutOfMemoryError
ãªãã·ã§ã³ãæå®ãã㨠Web ã¢ããªã±ã¼ã·ã§ã³ã®ãã°ãã¡ã¤ã«ã«ã¯Caused by: java.lang.OutOfMemoryError: Java heap space
ã®ãã°ã¯åºåããã¾ããã- ã©ã¡ãã®ãªãã·ã§ã³ãæå®ããªããã° Web ã¢ããªã±ã¼ã·ã§ã³ã¯çµäºãã¾ãããã¾ã Web ã¢ããªã±ã¼ã·ã§ã³ã®ãã°ãã¡ã¤ã«ã«
Caused by: java.lang.OutOfMemoryError: Java heap space
ã®ãã°ãåºåããã¾ãããã®ãã°ãåºåããã㨠OutOfMemory ãçºçãããã¡ã¤ã«ã¨è¡æ°ãåããã¾ãã - HeapDump ã¯
-XX:+ExitOnOutOfMemoryError
ãããã¯-XX:+CrashOnOutOfMemoryError
ãªãã·ã§ã³ã®æç¡ã¨ã¯å ¨ãé¢ä¿ããªãã-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=...
ãªãã·ã§ã³ãæå®ããã°åºåããã¾ãã
å人çãªææ³ã¨ãã¦ã¯ã
- OutOfMemory çºçæã« Web ã¢ããªã±ã¼ã·ã§ã³ã®ãã°ãã¡ã¤ã«ã«çºçç®æã®ãã¡ã¤ã«åãè¡çªå·ã®ãã°ãåºåãããæ¹ãããã¦ãã㤠Web ã¢ããªã±ã¼ã·ã§ã³ãçµäºããã¨ã©ã¼ãçºçãç¶ãã¦ãæ§ããªãã®ã§ããã°
-XX:+ExitOnOutOfMemoryError
ã-XX:+CrashOnOutOfMemoryError
ãæå®ãã¾ããã - Web ã¢ããªã±ã¼ã·ã§ã³ãçµäºããã°èªåçã«åèµ·åããä»çµã¿ããããWeb ã¢ããªã±ã¼ã·ã§ã³ã®ãã°ãã¡ã¤ã«ã«çºçç®æã®ãã¡ã¤ã«åãè¡çªå·ã®ãã°ãåºåãããå¿
è¦ããªãã®ã§ããã°
-XX:+CrashOnOutOfMemoryError
ãæå®ãã¦çµäºããããã«ãã¦ãã¨ã©ã¼ãã¡ã¤ã«ãçæãããããã«ãã¾ãã -XX:+ExitOnOutOfMemoryError
ãããã¯-XX:+CrashOnOutOfMemoryError
ãªãã·ã§ã³ãæå®ããï¼ããªãã«é¢ãããã-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=...
ãªãã·ã§ã³ã¯æå®ã㦠HeapDump ã¯åºåããæ¹ãããã§ãã-XX:+ExitOnOutOfMemoryError
ã¯åå¨æ義ãããåããã¾ããã§ãããHeapDump ã ã㧠OutOfMemory ã®åå ã調æ»ããã®ã¯é£ããæ°ããã¾ããä»ååºåããã HeapDump ã Memory Analyzer ã§éãã¦ã¿ã¾ããããä»åã®ãããªå®è£ ãåå ã§ããã°Caused by: java.lang.OutOfMemoryError: Java heap space
ã®ãã°ãåºã¦ãããæ¹ãåãããããããªãã¨æãã¾ããã
webapp_startup.bat ãä¿®æ£ãã
ãªãã·ã§ã³ãå¿ããªãããã«ããããã«ãwebapp_startup.bat ã«ã¯ -XX:+CrashOnOutOfMemoryError
ã追å ãããã¨ã«ãã¾ãã
@echo on setlocal set JAVA_HOME=C:\Java\jdk1.8.0_131 set PATH=%JAVA_HOME%\bin;%PATH% set WEBAPP_HOME=C:\webapps\ksbysample-webapp-lending set WEBAPP_JAR=ksbysample-webapp-lending-1.5.4-RELEASE.jar set LOGS_DIR=%WEBAPP_HOME%\logs set PATH_HEAPDUMPFILE=%LOGS_DIR%\heapdump.hprof set PATH_ERRORFILE=%LOGS_DIR%\hs_err.log cd /d %WEBAPP_HOME% java -server ^ -Xms1024m -Xmx1024m ^ -XX:MaxMetaspaceSize=384m ^ -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled ^ -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 ^ -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark ^ -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps ^ -Xloggc:%WEBAPP_HOME%/logs/gc.log ^ -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=10M ^ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%PATH_HEAPDUMPFILE% ^ -XX:+CrashOnOutOfMemoryError ^ -XX:ErrorFile=%PATH_ERRORFILE% ^ -Dsun.net.inetaddr.ttl=100 ^ -Dcom.sun.management.jmxremote ^ -Dcom.sun.management.jmxremote.port=7900 ^ -Dcom.sun.management.jmxremote.ssl=false ^ -Dcom.sun.management.jmxremote.authenticate=false ^ -Dspring.profiles.active=product ^ -jar lib\%WEBAPP_JAR% set YYYYMMDD=%date:~0,4%%date:~5,2%%date:~8,2% set HHMMSS=%time:~0,8% set HHMMSS=%HHMMSS::=% set HHMMSS=%HHMMSS: =% if exist %PATH_HEAPDUMPFILE% rename %PATH_HEAPDUMPFILE% heapdump_%YYYYMMDD%%HHMMSS%.hprof if exist %PATH_ERRORFILE% rename %PATH_ERRORFILE% hs_err_%YYYYMMDD%%HHMMSS%.log
å±¥æ´
2017/07/17
åççºè¡ã