0

I using springboot 1.5.4.RELEASE with java 1.8 and I create a controller that allow download a file from a restController this is my code:

@RequestMapping(value = "/validar/{hash}", produces =  MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody byte[] getArquivoFromHash(@PathVariable String hash) throws IOException {        
    return IOUtils.toByteArray(protocoloService.recuperarArquivoCertidaoAssinado(hash));

}

and my recuperarArquivoCertidaoAssinado returns a FileInputStream from a File

so when I try to download a large file (something like 50MB) I got the heapspace

java.lang.OutOfMemoryError: Java heap space

Fabio Ebner
  • 2,613
  • 16
  • 50
  • 77
  • How big is your JVMs heapsize ? Did you increase it ? – Marged Apr 03 '18 at 04:50
  • Possible duplicate of [How to increase Heap size of JVM](https://stackoverflow.com/questions/6452765/how-to-increase-heap-size-of-jvm) – Marged Apr 03 '18 at 04:52
  • But does not Java 8 not automatically allocate? I just give you an idea of when I want it, if I increase it it will only take a little longer to give problem – Fabio Ebner Apr 03 '18 at 14:45
  • No, there is a certain limit and you can increase this limit. Either you need a streaming approach or increase your heap to (number of concurrent connections * biggest file + base for application ) – Marged Apr 03 '18 at 21:54

0 Answers0