java.lang.OutOfMemoryError: Requested array size exceeds VM limit

Spring JIRA | ChangMin Jeon | 3 years ago
  1. 0

    There is out of memory occured when responding big file data using ShallowEtagHeaderFilter. We configured mvc like below. <!-- Enables the Spring MVC @Controller programming model --> <mvc:annotation-driven/> <mvc:default-servlet-handler /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <!-- mvc:resources mapping="/resources/**" location="/resources/" /--> <mvc:resources mapping="/data/**" location="file:${config.uploadDir}\" /> For example, If a client request resource with http://localhost/data/content/a.zip(1GBytes) then following stack trace is shown. But It's normal when commenting out ETAG filter configuration. I also attached spring's web.xml and apache tomcat's web.xml. java.lang.OutOfMemoryError: Requested array size exceeds VM limit at java.util.Arrays.copyOf(Unknown Source) at java.io.ByteArrayOutputStream.grow(Unknown Source) at java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source) at java.io.ByteArrayOutputStream.write(Unknown Source) at org.springframework.web.filter.ShallowEtagHeaderFilter$ShallowEtagResponseWrapper$ResponseServletOutputStream.write(ShallowEtagHeaderFilter.java:245) at org.springframework.util.StreamUtils.copy(StreamUtils.java:125) at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:109) at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.writeContent(ResourceHttpRequestHandler.java:244) at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:145) at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:73) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)

    Spring JIRA | 3 years ago | ChangMin Jeon
    java.lang.OutOfMemoryError: Requested array size exceeds VM limit
  2. 0

    There is out of memory occured when responding big file data using ShallowEtagHeaderFilter. We configured mvc like below. <!-- Enables the Spring MVC @Controller programming model --> <mvc:annotation-driven/> <mvc:default-servlet-handler /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <!-- mvc:resources mapping="/resources/**" location="/resources/" /--> <mvc:resources mapping="/data/**" location="file:${config.uploadDir}\" /> For example, If a client request resource with http://localhost/data/content/a.zip(1GBytes) then following stack trace is shown. But It's normal when commenting out ETAG filter configuration. I also attached spring's web.xml and apache tomcat's web.xml. java.lang.OutOfMemoryError: Requested array size exceeds VM limit at java.util.Arrays.copyOf(Unknown Source) at java.io.ByteArrayOutputStream.grow(Unknown Source) at java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source) at java.io.ByteArrayOutputStream.write(Unknown Source) at org.springframework.web.filter.ShallowEtagHeaderFilter$ShallowEtagResponseWrapper$ResponseServletOutputStream.write(ShallowEtagHeaderFilter.java:245) at org.springframework.util.StreamUtils.copy(StreamUtils.java:125) at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:109) at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.writeContent(ResourceHttpRequestHandler.java:244) at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:145) at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:73) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)

    Spring JIRA | 3 years ago | ChangMin Jeon
    java.lang.OutOfMemoryError: Requested array size exceeds VM limit
  3. 0

    [JENKINS-22816] SocketException on copy artifact after upgrad - Jenkins JIRA

    jenkins-ci.org | 4 months ago
    java.lang.OutOfMemoryError: Requested array size exceeds VM limit
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Java: why is there a difference in memory usage between for- and while-loops?

    Stack Overflow | 2 years ago | Chthonic Project
    java.lang.OutOfMemoryError: Requested array size exceeds VM limit
  6. 0

    OutOfMemoryError while writing a large map to a file

    avro-user | 10 months ago | David Kincaid
    java.lang.OutOfMemoryError: Requested array size exceeds VM limit

    8 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.OutOfMemoryError

      Requested array size exceeds VM limit

      at java.util.Arrays.copyOf()
    2. Java RT
      ByteArrayOutputStream.write
      1. java.util.Arrays.copyOf(Unknown Source)
      2. java.io.ByteArrayOutputStream.grow(Unknown Source)
      3. java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source)
      4. java.io.ByteArrayOutputStream.write(Unknown Source)
      4 frames
    3. Spring
      ShallowEtagHeaderFilter$ShallowEtagResponseWrapper$ResponseServletOutputStream.write
      1. org.springframework.web.filter.ShallowEtagHeaderFilter$ShallowEtagResponseWrapper$ResponseServletOutputStream.write(ShallowEtagHeaderFilter.java:245)
      1 frame
    4. Spring Core
      FileCopyUtils.copy
      1. org.springframework.util.StreamUtils.copy(StreamUtils.java:125)
      2. org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:109)
      2 frames
    5. Spring MVC
      FrameworkServlet.doGet
      1. org.springframework.web.servlet.resource.ResourceHttpRequestHandler.writeContent(ResourceHttpRequestHandler.java:244)
      2. org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:145)
      3. org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
      4. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      5. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      6. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      7. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      7 frames
    6. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      1 frame
    7. Spring MVC
      FrameworkServlet.service
      1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      1 frame
    8. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      1 frame
    9. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      2 frames
    10. Spring
      OncePerRequestFilter.doFilter
      1. org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:73)
      2. org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      2 frames
    11. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      2 frames
    12. Spring Security
      AnonymousAuthenticationFilter.doFilter
      1. org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
      2. org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
      3. org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
      4. org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
      5. org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
      6. org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
      7. org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
      8. org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
      9. org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
      9 frames