Download servlet throwing java heap space exception
<p>I have a search function in which i am returning all the records of the entities to a user on searh button , now matter how much the records are(right now, it is able to search 50,000 records). now i am trying to download all these records in a csv .if the records are less, then its working fine , but when its more than 30,000, it is throwing       </p>

<p>Edited:-</p>

<p>Solution:- used these lines of code </p>

<pre><code>            InputStream in = new ByteArrayInputStream(buffer.toString().getBytes("UTF-8"));
            ServletOutputStream out = response.getOutputStream();

           byte[] outputByte = new byte[4096];

             while(in.read(outputByte, 0, 4096) != -1)
                {
                   out.write(outputByte, 0, 4096);
                  }
         in.close();
            out.flush();
              out.close();*/
</code></pre>
