what is java.lang.OutOfMemoryError and how to fix it
by
Seyyed Shah
Some of you may have experienced the following error:
"main" java.lang.OutOfMemoryError: Java heap space
when using the
words-large and
words-larger dictionaries (the largest of which is only 8MB) in Question 3 of the current assignment.
This happens because the Java Virtual Machine (JVM) has a fixed maximum memory footprint (normally 128MB) and in some cases that memory can be completely used up. You should also careful check that memory is being used efficiently by your program. For example if you are creating many objects (e.g. Strings) that don't need to be created, this will cause memory to run out.
In any case you can increase the amount of memory available to the virtual machine on the command line:
java -Xms128m -Xmx1024m PredictiveListin netBeans you can change your project heap size from "Project Properties" by adding "-Xms128m -Xmx1024m" without quotes to the "VM Options" text field, under "run" :

will increase the maximum amount of memory available to your program to 1024MB i.e. 1GB (as well as increasing the minimum available to 128MB)
Post a Comment