OutOfMemoryError downloading big file through Seam.DownloadFile operation

I have an automation chain which produces a FileBlob referencing a ZIP file on the server, then calls Seam.DownloadFile 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. Seam.DownloadFile failed with this stack trace:

Caused by: java.lang.OutOfMemoryError: Java heap space
        at org.ajax4jsf.io.ByteBuffer.<init>(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)

It appears that Ajax4JSF was trying to buffer the entire file content in memory.

I found mention of this issue on NXP-2602, but that report is really about file upload and it's marked as resolved.

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?

0 votes

0 answers

1400 views

ANSWER