0

I am trying to read a file which size is 1.29gb and I am getting this error. I also tried by increasing and decreasing the VM option(-XX:MaxHeapSize=1500m)

"Error occurred during initialization of VM Could not reserve enough space for 1536000KB object heap C:\Users\MM COMPUTER\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)"

andrewJames
  • 19,570
  • 8
  • 19
  • 51
  • 1
    do you have to read the entire 1.29gb into memory? can't you process it in chunks? java.nio has pretty cool api for mapping files. you should prolly check it out. – Ace Nov 28 '20 at 19:14
  • yes I have to read the total 1.29gb file. Is there any other way to read the full file instead of breaking it? – Anik Karmaker Nov 28 '20 at 19:16
  • you never know your problem might be solvable if you just read the file in chunks, it'll prolly be faster to process too, mind tell us why it has to be all in memory? – Ace Nov 28 '20 at 19:25
  • it is basically a json file which contains all my data. So I can not break it down and the file is too big to open with any text editor. – Anik Karmaker Nov 28 '20 at 19:31
  • 2
    of course you can break down "the reading" process. I wasn't talking about breaking your file outside of your program. Keep it one piece, but _read_ it in chunks. If your objective is to parse it, check [this](https://stackoverflow.com/a/9460267/3438172) answer, see if it helps. – Ace Nov 28 '20 at 19:39
  • 1
    Hello @AnikKarmaker, it is always helpful to share the code you are using to read the file. With Java, there are multiple ways this can be done, so it is critical to know how you are doing it to get a relevant answer. – Samuel Owino Nov 28 '20 at 22:03

0 Answers0