0

Is it possible to add memory in JVM more than 5GB if the machine has installed memory 2GB only?

Because I got exception in thread, java.lang.OutOfMemoryError: Java heap space

I'm reading a text file which contains Strings that sized by 5gb, and I used BufferedReader to read lines.

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
tuturyokgaming
  • 249
  • 1
  • 8
  • 21

1 Answers1

0

Just process the data a line at a time, with readLine() and friends, maybe even a Scanner. It is never necessary to load a large file entirely into memory.

user207421
  • 305,947
  • 44
  • 307
  • 483