I'm trying to execute a java script on a large text file, but it gives me this error
java.lang.OutOfMemoryError: Java heap space
I tried to do that on my netbeans project:
Project Properties -> Run -> VM Options -> -Xmx2048m -Xms1024m
I tried also :
System -> Programs -> Java -> Java -> View -> Execution Parameters -> -Xincgc -Xmx2048M
But i didn't solve the problem .. any suggestions please ?
I would suggest altering your code, the other alternative is described in here: http://wiki.netbeans.org/FaqSettingHeapSize
String storage can be quite expensive. Using random String of avarage ~ 80 chars long, 3 000 000 strings can cosume almoust 1GB
Output: Count:3000000 Memory:981.5
Try to wrap your piece of code where you are reading your file with the same
try-finally
block i have made here. When error will popout, you will get approx ammount of memory you are consuming at that point, and what percentage of file you have managed already to read. This will get you the idea of how much more memory you will need.Moreover you will know if your
-Xmx
directive works, because if it will crash around lets say 500mb it is either ommited by netbeans, or there is no mo available memory it the system.