I was trying to run an Java application of reading a file of 15MB file. But I am facing an issue with java.lang.OutOfMemoryError Java heap space error.
1 Answer
Either you change the code so that it uses less memory (for example, by only reading chunks of the file and not reading everything in memory), or you give more memory to your JVM:
java -Xmx512m ...
The above sets the maximum heap space to 512 MBs.
Its impossible to give a more precise answer on how to optimize the code without seeing the code.