Isomorphic SmartClient/SmartGWT Framework (v9.0p_2014-02-13/PowerEdition Deployment 2014-02-13)
I'm having an issue with using FileItem with large files.
Here is what the code looks like on the UI Side:
DynamicForm fileForm = new DynamicForm();
fileForm.setEncoding( Encoding.MULTIPART );
fileForm.setDataSource( DataSource.get( FileFormDataSourceFields.DATASOURCE_NAME ) );
final FileItem fileItem = new FileItem( FileFormDataSourceFields.FILE, "File" );
fileItem.setMultiple( false );
fileItem.setRequired( Boolean.TRUE );
final TextItem displayName = new TextItem( FileFormDataSourceFields.NAME, "Display Name" );
displayName.setRequired( Boolean.TRUE );
fileForm.setFields( fileItem, displayName );
On the serverside, I get access to the list of ISCFileItem objects (in my case there will only be one because it is not a multi-file upload), and I access the byte[] array through the call to get().
This works with files under 250M, but anything larger, and the server runs out of memory.
From the log:
[DEBUG][02/14/2014 11:43:16:904] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:908] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:908] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:908] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[ERROR][02/14/2014 11:43:16:909] org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper - Top-level servlet error: (com.isomorphic.servlet.IDACall)
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:122)
at java.io.FilterOutputStream.write(FilterOutputStream.java:77)
at com.isomorphic.io.ByteCountingOutputStream.write(ByteCountingOutputStream.java:45)
at java.io.FilterOutputStream.write(FilterOutputStream.java:125)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:101)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:64)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:310)
at com.isomorphic.servlet.ISCHttpServletRequest.parseRequest(ISCHttpServletRequest.java:247)
at com.isomorphic.servlet.ISCHttpServletRequest.parseRequest(ISCHttpServletRequest.java:219)
at com.isomorphic.servlet.ISCHttpServletRequest.getStringParams(ISCHttpServletRequest.java:119)
at com.isomorphic.servlet.ISCHttpServletRequest.getParameter(ISCHttpServletRequest.java:300)
at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:2017)
at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:306)
at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:286)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:384)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
So, this looks like all of the file is streamed into memory. This causes the server to run out of memory with large files. I'm also worried that even with small files, if enough users are uploading at the same time, this same issue would occur. I can't find an option to tell SmartGWT to stream the file data into a temporary file instead of keeping it all in memory. How can I do this in order to prevent OutOfMemory errors?
I'm having an issue with using FileItem with large files.
Here is what the code looks like on the UI Side:
DynamicForm fileForm = new DynamicForm();
fileForm.setEncoding( Encoding.MULTIPART );
fileForm.setDataSource( DataSource.get( FileFormDataSourceFields.DATASOURCE_NAME ) );
final FileItem fileItem = new FileItem( FileFormDataSourceFields.FILE, "File" );
fileItem.setMultiple( false );
fileItem.setRequired( Boolean.TRUE );
final TextItem displayName = new TextItem( FileFormDataSourceFields.NAME, "Display Name" );
displayName.setRequired( Boolean.TRUE );
fileForm.setFields( fileItem, displayName );
On the serverside, I get access to the list of ISCFileItem objects (in my case there will only be one because it is not a multi-file upload), and I access the byte[] array through the call to get().
This works with files under 250M, but anything larger, and the server runs out of memory.
From the log:
[DEBUG][02/14/2014 11:43:16:904] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:905] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:906] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:907] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:908] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:908] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[DEBUG][02/14/2014 11:43:16:908] filled 16384/16384 (org.eclipse.jetty.http.HttpParser)
[ERROR][02/14/2014 11:43:16:909] org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper - Top-level servlet error: (com.isomorphic.servlet.IDACall)
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:122)
at java.io.FilterOutputStream.write(FilterOutputStream.java:77)
at com.isomorphic.io.ByteCountingOutputStream.write(ByteCountingOutputStream.java:45)
at java.io.FilterOutputStream.write(FilterOutputStream.java:125)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:101)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:64)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:310)
at com.isomorphic.servlet.ISCHttpServletRequest.parseRequest(ISCHttpServletRequest.java:247)
at com.isomorphic.servlet.ISCHttpServletRequest.parseRequest(ISCHttpServletRequest.java:219)
at com.isomorphic.servlet.ISCHttpServletRequest.getStringParams(ISCHttpServletRequest.java:119)
at com.isomorphic.servlet.ISCHttpServletRequest.getParameter(ISCHttpServletRequest.java:300)
at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:2017)
at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:306)
at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:286)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:384)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
So, this looks like all of the file is streamed into memory. This causes the server to run out of memory with large files. I'm also worried that even with small files, if enough users are uploading at the same time, this same issue would occur. I can't find an option to tell SmartGWT to stream the file data into a temporary file instead of keeping it all in memory. How can I do this in order to prevent OutOfMemory errors?
Comment