FYI:
Became a bit interested and implemented a small test app that sends a large csv file and found the following:
OutOfMemoryException happens in the constructor for org.ajax4jsf.io.ByteBuffer(int cacheSize), when the exception occur the value of cacheSize is 268435456 (running in Eclipse with lots of memory).
What happens is that the append method tries to double the size of the ByteBuffer :(
Wonder if it is possible to bypass the richfaces/ajax4jsf framework for certain urls?
The first 3 classes below belong to ajax4jsf.
Daemon Thread [http-8080-Processor4] (Suspended (exception OutOfMemoryError))
ByteBuffer.<init>(int) line: 54
ByteBuffer.append(byte[], int, int) line: 112
FastBufferOutputStream.write(byte[]) line: 92
FilterServletResponseWrapper$ByteArrayServletOutputStream.write(byte[]) line: 276
DownloadBacking.fileDownload() line: 44
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
Reflections.invoke(Method, Object, Object...) line: 21
RootInvocationContext.proceed() line: 31
SeamInvocationContext.proceed() line: 56
RollbackInterceptor.aroundInvoke(InvocationContext) line: 31
SeamInvocationContext.proceed() line: 68
BusinessProcessInterceptor.aroundInvoke(InvocationContext) line: 49
SeamInvocationContext.proceed() line: 68
MethodContextInterceptor.aroundInvoke(InvocationContext) line: 42
SeamInvocationContext.proceed() line: 68
JavaBeanInterceptor(RootInterceptor).invoke(InvocationContext, EventType) line: 107
JavaBeanInterceptor.interceptInvocation(Method, Object[]) line: 166
JavaBeanInterceptor.invoke(Object, Method, Method, Object[]) line: 102
DownloadBacking_$$_javassist_3.fileDownload() line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
ReflectionUtil.invokeMethod(Object, Method, Object[]) line: 329
ReflectionUtil.invokeMethod(Object, Object, Class[], Object[]) line: 342
AstPropertySuffix.invoke(Object, EvaluationContext, Class[], Object[]) line: 58
AstValue.invoke(EvaluationContext, Class[], Object[]) line: 96
MethodExpressionImpl.invoke(ELContext, Object[]) line: 276
TagMethodExpression.invoke(ELContext, Object[]) line: 68
MethodBindingMethodExpressionAdapter.invoke(FacesContext, Object[]) line: 88
ActionListenerImpl.processAction(ActionEvent) line: 102
HtmlCommandButton(UICommand).broadcast(FacesEvent) line: 387
AjaxViewRoot.processEvents(FacesContext, EventsQueue, boolean) line: 317
AjaxViewRoot.broadcastEvents(FacesContext, PhaseId) line: 292
AjaxViewRoot.processPhase(FacesContext, PhaseId, InvokerCallback) line: 249
AjaxViewRoot.processApplication(FacesContext) line: 462
InvokeApplicationPhase.execute(FacesContext) line: 82
InvokeApplicationPhase(Phase).doPhase(FacesContext, Lifecycle, ListIterator<PhaseListener>) line: 100
LifecycleImpl.execute(FacesContext) line: 118
FacesServlet.service(ServletRequest, ServletResponse) line: 265
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 252
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 173
SeamFilter$FilterChainImpl.doFilter(ServletRequest, ServletResponse) line: 83
ExceptionFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 64
SeamFilter$FilterChainImpl.doFilter(ServletRequest, ServletResponse) line: 69
RedirectFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 45
SeamFilter$FilterChainImpl.doFilter(ServletRequest, ServletResponse) line: 69
ConfigurableXMLFilter(BaseXMLFilter).doXmlFilter(FilterChain, HttpServletRequest, HttpServletResponse) line: 154
Filter(BaseFilter).handleRequest(HttpServletRequest, HttpServletResponse, FilterChain) line: 260
Filter(BaseFilter).processUploadsAndHandleRequest(HttpServletRequest, HttpServletResponse, FilterChain) line: 366
Filter(BaseFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 493
Ajax4jsfFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 60
SeamFilter$FilterChainImpl.doFilter(ServletRequest, ServletResponse) line: 69
LoggingFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 58
SeamFilter$FilterChainImpl.doFilter(ServletRequest, ServletResponse) line: 69
HotDeployFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 68
SeamFilter$FilterChainImpl.doFilter(ServletRequest, ServletResponse) line: 69
SeamFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 158
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 202
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 173
StandardWrapperValve.invoke(Request, Response) line: 213
StandardContextValve.invoke(Request, Response) line: 178
NonLoginAuthenticator(AuthenticatorBase).invoke(Request, Response) line: 432
StandardHostValve.invoke(Request, Response) line: 126
ErrorReportValve.invoke(Request, Response) line: 105
StandardEngineValve.invoke(Request, Response) line: 107
CoyoteAdapter.service(Request, Response) line: 148
Http11Processor.process(InputStream, OutputStream) line: 869
Http11Protocol$JmxHttp11ConnectionHandler(Http11BaseProtocol$Http11ConnectionHandler).processConnection(TcpConnection, Object[]) line: 667
PoolTcpEndpoint.processSocket(Socket, TcpConnection, Object[]) line: 527
LeaderFollowerWorkerThread.runIt(Object[]) line: 80
ThreadPool$ControlRunnable.run() line: 684
ThreadWithAttributes(Thread).run() line: 619