-1
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3236)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)`

Trying to download file greater than 90MB. I'm getting exception when calling Object.getBytes(). Could you please help me to resolve this issue?

wolf
  • 107
  • 10
Leela
  • 9
  • 6
  • 1
    The file goes from where to where ? – azro Aug 08 '17 at 19:01
  • 1
    Can you please add more details? source code, config files etc.. – Sairam Kukadala Aug 08 '17 at 19:02
  • 2
    Possible duplicate of [How to deal with "java.lang.OutOfMemoryError: Java heap space" error (64MB heap size)](https://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap) – Jacob G. Aug 08 '17 at 19:03

2 Answers2

0

You're trying to read a 90mb file into a JVM that is only 64mb by default. You can change the memory settings from the command line:

-Xms128m -Xmx256m

This will set the initial size of the JVM to 128mb and the maximum size to 256mb. You can of course change them to suit your needs.

user6629913
  • 172
  • 1
  • 14
0
InputStream inputStream = object.getStream(); , resolves this issue.Im able to download 2GB files as well.
Leela
  • 9
  • 6