Question

I am using a SOLVER to solve an issue in Java using OptaPlanner but after some point of time, i get an exception saying Java.lang.OutOfMemoryError: Java Heap Space. What does this signify

Était-ce utile?

La solution

JVM-Java Virtual Machine will limit your execution with some space of memory if you exceed the allocated memory you got to experience this "JAVA HEAP SPACE" ERROR.

You can also increase the Heap space by doing this,

java -Xms<initial heap size> -Xmx<maximum heap size> CLASS_FILE_TO_EXECUTE

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size

Ie

java -Xmx2g assign 2 gigabytes of ram as maximum to your app

But you should see if you don't have a memory leak first.

Autres conseils

Btw What is meant above: adjust the -Xmx setting in runExamples.bat or .sh file in: optaplanner-distribution-6.0.1.Final\examples\ (by default it is 512m). What I do to circumvent this problem and getting better results: I monitor the progress by checking MEM usage in Windows Task Manager. When it gets close to the max value I hit the "Terminate solving early" button. Than I click Save As and store a file in the "Solved" folder. Than I kill all OptaPlanner windows and restart it afresh. In "Quick Open" window I click on the file I just saved and hit Solve again. It will lower the number of Soft Constraints violated a bit better till I see the MEM is close to the limit again. I do this a couple of times till I see 2-3 times that I don't get better results. TADA, workaround.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top