I\'m trying to increase the heap size in java for weka which keeps crashing. I used the suggested line:
> java -Xmx500m -classpath
but
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.
If we are using Weka Workbench CLI or Knowledge explorer we need to change as below.
As the documentation suggests the runtime parameter should be -Xmx[size_required]m where [size_required] is memory size you intend to keep to avoid memory exception.
Open RunWeka.ini
Define maxheap=[size_required]G
In my case I kept maxheap=4G , One can set like maxheap=4096m and add -Xmx#maxheap# to all the run options at # setups (prefixed with "cmd_") sections next to java commands like below
cmd_default=javaw -Xmx#maxheap# ...............
cmd_console=cmd.exe /K start cmd.exe ..................
cmd_explorer=java -Xmx#maxheap# .................
cmd_knowledgeFlow=java -Xmx#maxheap#....................
maxheap=4G
Verify the same by restarting Weka and Help>>SystemInfo
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.
The official Weka answer is right..But....crucial is to first get rid of all JVM files and install the relevant 32 or 64 bit Java version. Not using the relevant version causes many problems including the impossibility to increase the heap further than 1024m (by changing the ini file).
If you run weka from the command line but not through java i.e. typing weka
into the command line, instead of typing
weka
specify the memory flag
weka -m 1024m
This will specify 1024 megabytes.
If you're running weka via weka.sh, you can directly run it with memory option. For example,
sh weka.sh -memory 10g
This will increase the heap size to 10Gb (tested using Weka 3.8.4 on Ubuntu 18.04)