<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OutOfMemoryError downloading big file through Seam.DownloadFile operation in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/outofmemoryerror-downloading-big-file-through-seam-downloadfile/m-p/313098#M99</link>
    <description>&lt;P&gt;I have an automation chain which produces a FileBlob referencing a ZIP file on the server, then calls &lt;CODE&gt;Seam.DownloadFile&lt;/CODE&gt; to download the ZIP file to the web client. Someone tested it with a 465 MB ZIP file, while Nuxeo's JVM was limited to 1 GB of memory. &lt;CODE&gt;Seam.DownloadFile&lt;/CODE&gt; failed with this stack trace:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Caused by: java.lang.OutOfMemoryError: Java heap space
        at org.ajax4jsf.io.ByteBuffer.&amp;lt;init&amp;gt;(ByteBuffer.java:54)
        at org.ajax4jsf.io.ByteBuffer.append(ByteBuffer.java:112)
        at org.ajax4jsf.io.FastBufferOutputStream.write(FastBufferOutputStream.java:107)
        at org.ajax4jsf.webapp.FilterServletResponseWrapper$ByteArrayServletOutputStream.write(FilterServletResponseWrapper.java:277)
        at org.nuxeo.ecm.core.api.impl.blob.AbstractBlob.copy(AbstractBlob.java:48)
        at org.nuxeo.ecm.core.api.impl.blob.AbstractBlob.transferTo(AbstractBlob.java:77)
        at org.nuxeo.ecm.platform.ui.web.util.ComponentUtils.download(ComponentUtils.java:222)
        at org.nuxeo.ecm.automation.jsf.operations.DownloadFile.run(DownloadFile.java:44)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It appears that Ajax4JSF was trying to buffer the entire file content in memory.&lt;/P&gt;
&lt;P&gt;I found mention of this issue on &lt;A href="https://jira.nuxeo.com/browse/NXP-2602"&gt;NXP-2602&lt;/A&gt;, but that report is really about file upload and it's marked as resolved.&lt;/P&gt;
&lt;P&gt;We could raise the JVM memory limit, but that's not really a solution. Is there another way to accomplish this that wouldn't try to buffer the file content in memory? A different blob type? A different Seam.DownloadXXX operation?&lt;/P&gt;</description>
    <pubDate>Thu, 22 May 2014 18:53:16 GMT</pubDate>
    <dc:creator>Kenster_</dc:creator>
    <dc:date>2014-05-22T18:53:16Z</dc:date>
    <item>
      <title>OutOfMemoryError downloading big file through Seam.DownloadFile operation</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/outofmemoryerror-downloading-big-file-through-seam-downloadfile/m-p/313098#M99</link>
      <description>&lt;P&gt;I have an automation chain which produces a FileBlob referencing a ZIP file on the server, then calls &lt;CODE&gt;Seam.DownloadFile&lt;/CODE&gt; to download the ZIP file to the web client. Someone tested it with a 465 MB ZIP file, while Nuxeo's JVM was limited to 1 GB of memory. &lt;CODE&gt;Seam.DownloadFile&lt;/CODE&gt; failed with this stack trace:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Caused by: java.lang.OutOfMemoryError: Java heap space
        at org.ajax4jsf.io.ByteBuffer.&amp;lt;init&amp;gt;(ByteBuffer.java:54)
        at org.ajax4jsf.io.ByteBuffer.append(ByteBuffer.java:112)
        at org.ajax4jsf.io.FastBufferOutputStream.write(FastBufferOutputStream.java:107)
        at org.ajax4jsf.webapp.FilterServletResponseWrapper$ByteArrayServletOutputStream.write(FilterServletResponseWrapper.java:277)
        at org.nuxeo.ecm.core.api.impl.blob.AbstractBlob.copy(AbstractBlob.java:48)
        at org.nuxeo.ecm.core.api.impl.blob.AbstractBlob.transferTo(AbstractBlob.java:77)
        at org.nuxeo.ecm.platform.ui.web.util.ComponentUtils.download(ComponentUtils.java:222)
        at org.nuxeo.ecm.automation.jsf.operations.DownloadFile.run(DownloadFile.java:44)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It appears that Ajax4JSF was trying to buffer the entire file content in memory.&lt;/P&gt;
&lt;P&gt;I found mention of this issue on &lt;A href="https://jira.nuxeo.com/browse/NXP-2602"&gt;NXP-2602&lt;/A&gt;, but that report is really about file upload and it's marked as resolved.&lt;/P&gt;
&lt;P&gt;We could raise the JVM memory limit, but that's not really a solution. Is there another way to accomplish this that wouldn't try to buffer the file content in memory? A different blob type? A different Seam.DownloadXXX operation?&lt;/P&gt;</description>
      <pubDate>Thu, 22 May 2014 18:53:16 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/outofmemoryerror-downloading-big-file-through-seam-downloadfile/m-p/313098#M99</guid>
      <dc:creator>Kenster_</dc:creator>
      <dc:date>2014-05-22T18:53:16Z</dc:date>
    </item>
  </channel>
</rss>

