Question: I get a java.lang.outOfMemoryError exception, while writing a big file to the servletOutputStream.
Every response is by default wrapped using a ehcache.constructs.web.filter Object for GZIP compression. And as per the logs, the exception is thrown in the Filter object.
Is there a way to increase the available memory so, that the outOfMemoryError Exception does not occur ?

Answer: 
You need to add the option "-Xmx1024m" to the `java` command which runs your servlet container. (Replace 1024m with whatever heap size you like; this means 1024 megabytes.) If you're using, say, Tomcat, then this means you set this in the environment variable CATALINA\_OPTS. Your server configuration will vary.

However, the problem is buffering such a big file in memory. This is wasteful. Try this compression filter, which doesn't buffer this way:

<http://sourceforge.net/projects/pjl-comp-filter/>
Set the following JVM options to your servlet container `-Xmx256m -Xms128m` (in Tomcat it is in `catalina.sh` / `catalina.bat`)