Increase heap size in java for weka

What I found was the actual issue was in the file 'RunWeka.ini' in '\Program Files (x86)\Weka-3-6'. I opened it with notepad and in the middle of the file there is a line 'maxheap = 512m'.

I changed the line to read 'maxheap=2000m', saved the file and reloaded weka and this fixed my problems.

I'm not sure if this is the correct way to do it or not but it worked for me.


If you're using Weka 3.8.1 on Windows you can save yourself a lot of trouble by editing the javaOpts parameter. The parameter maxheap isn't used anymore, so you can set javaOpts like this in RunWeka.ini file:

javaOpts= -Xmx1040m

Where 1040m is the amount of memory you want to allocate.

Mind that the file is case sensitive.

There are a lot of ways to set this up, but this is the faster way to get Weka runing on a Windows environment at this version.

Edit: If you want Weka to use more than 1gb on windows, you need to have JDK installed. Regular JRE wont do it.


Omit the -classpath option. Use just -Xmx500m option.

So, instead of just:

java weka.core.Instances data/soybean.arff

you do:

java -Xmx500m weka.core.Instances data/soybean.arff

If you run weka via some script (RunWeka.bat for example), then you need to modify that script (with some text editor like notepad).


Run this command in your terminal:

java -Xmx1024m -jar weka.jar