Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-19111

java.lang.OutOfMemoryError when uploading a larger size file

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Blocker
    • 14.2-rc-1, 13.10.4
    • 13.0
    • Distribution
    • Windows 10 Pro 64 bit, Edge 95, using a local instance XWiki 13.4.5 and 13.9 on Standard Jetty/HSQLDB, XWiki 13.4.3 on tomcat, XWiki 14.1 on tomcat 9 on Ubuntu
    • Unknown
    • N/A
    • N/A

    Description

      STEPS TO REPRODUCE

      1. Download and start a standard Jetty/HSQL instance of XWiki 13.9 or 13.4.5
      2. Go to a page and upload a file with a larger size (tested with 144 MB and 200 MB)

      EXPECTED RESULTS

      The file is attached successfully to the page.

      ACTUAL RESULTS

      The file cannot be uploaded. An error message is displayed on the page:

      An error occurred while uploading File.zip

      In XWiki console, there is the following stacktrace:

      [Restlet] Attaching application: org.xwiki.rest.internal.XWikiRestletJaxRsApplication@5411a068 to URI: /xwiki/rest
      java.lang.OutOfMemoryError: Java heap space
      Dumping heap to data\java_pid14208.hprof ...
      Heap dump file created [800866869 bytes in 0.837 secs]
      2021-11-04 15:44:16,525 [qtp724125922-19 - http://localhost:1392/xwiki/bin/upload/Main/WebHome] WARN  c.x.x.w.XWikiAction            - Uncaught exception: Error number 0 in 11: Uncaught exception
      com.xpn.xwiki.XWikiException: Error number 0 in 11: Uncaught exception
              at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:617)
              at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:289)
              at com.xpn.xwiki.web.LegacyActionServlet.service(LegacyActionServlet.java:115)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
              at org.eclipse.jetty.servlet.ServletHolder$NotAsyncServlet.service(ServletHolder.java:1411)
              at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1631)
              at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:122)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:61)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:226)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
              at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:549)
              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
              at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:602)
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
              at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)
              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
              at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1369)
              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
              at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:489)
              at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)
              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
              at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1284)
              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
              at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:221)
              at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
              at org.eclipse.jetty.server.Server.handle(Server.java:501)
              at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
              at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
              at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
              at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
              at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
              at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
              at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
              at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
              at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
              at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
              at java.base/java.lang.Thread.run(Thread.java:833)
      Caused by: java.lang.OutOfMemoryError: Java heap space
              at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
              at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:228)
              at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:740)
              at java.base/java.lang.StringBuilder.append(StringBuilder.java:229)
              at org.apache.commons.io.output.StringBuilderWriter.write(StringBuilderWriter.java:143)
              at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1433)
              at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1411)
              at org.apache.commons.io.IOUtils.copy(IOUtils.java:1208)
              at org.apache.commons.io.IOUtils.copy(IOUtils.java:1022)
              at org.apache.commons.io.IOUtils.toString(IOUtils.java:2839)
              at org.apache.commons.io.IOUtils.toString(IOUtils.java:2865)
              at com.xpn.xwiki.internal.fileupload.PartFileItem.getString(PartFileItem.java:118)
              at com.xpn.xwiki.web.Utils.handleMultipart(Utils.java:619)
              at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:512)
              at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:289)
              at com.xpn.xwiki.web.LegacyActionServlet.service(LegacyActionServlet.java:115)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
              at org.eclipse.jetty.servlet.ServletHolder$NotAsyncServlet.service(ServletHolder.java:1411)
              at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1631)
              at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:122)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:61)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:226)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
              at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)

      I've tested with a 100 MB file and it worked.

      The issue reproduces also on XWiki 13.1 (tested with 13.4.5 as well), but could not be reproduced on a standard Jetty/HSQLDB instance of XWiki 12.10.10. It's possible that it was introduced before 13.1 (wasn't tested).

      Attachments

        1. Cannot_upload_144MB.png
          40 kB
          Ilie Andriuta
        2. Cannot_upload_200MB.png
          59 kB
          Ilie Andriuta
        3. JavaHeapSpace.jpg
          111 kB
          Gabriela Anechitoaei
        4. JavaHeapSpace2.jpg
          62 kB
          Gabriela Anechitoaei

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              iandriuta Ilie Andriuta
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: