I have come across heap errors while loading a large dataset into Jena. `Is there some way by which I may allocate the JVM(Java) a large heap space.
I know I can achieve this by making changes into eclipse.ini. But is there some way by which I may increase the Java heap size using command line in linux (I using a 64GB RAM server: running 12.04 Ubuntu LTS server)?
The error which I am getting due to less heap space is: exception in thread main gc overhead limit exceeded.
Also how can I find the maximum amount of heap space which I can set for my systems
I tried export JAVA_OPTS= -Xms4096m -Xmx4096m but ended up getting the error:
bash: export: -Xms4096m': not a valid identifier
bash: export:-Xmx4096m': not a valid identifier
Try (note quotes are not optional with two words)
export JAVA_OPTS="-Xms4096m -Xmx4096m"
Or, even
export MIN="4096m" # <-- Those quotes are (one word).
export MAX="4096m"
export JAVA_OPTS="-Xms$MIN -Xmx$MAX" # <-- single quotes would break variable expansion
java -Xms4096m -Xmx4096m [YourAppHere]
This command will allocate 4GB (or 4096 MB) of heap memory at the start (the -Xms4096m option), and will have a maximum heap memory size of 4GB (the -Xmx4096m option).
Obviously you can change the number to whatever sizes you want to. There is overhead if the computer has to increase the size of memory (Every time it increases the memory size, it doubles the allocation) so if you have that much ram, you might as well just allocate it at the beginning of the app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With