Setting Java Heap Size under Apache Karaf

Tony picture Tony · Sep 8, 2011 · Viewed 17.5k times · Source

I apologize if this is a duplicate, but I can't seem to find this answered anywhere.

What is the best way to increase the maximum Java heap size when using Apache Karaf?

Currently, I modified the following line in the karaf.bat file:

set DEFAULT_JAVA_OPTS=-server -Xmx<NewMaxValue>M.

I feel like modifying the bat file is not the best solution. Additionally, none of the config files seem to have a place to put this.

Thanks

Answer

el.atomo picture el.atomo · Jul 16, 2013

(At least) in karaf 2.2.10:

If running karaf through bin/start

As Ford Guo pointed out, memory values could be configured in the bin/setenv file:

export JAVA_MIN_MEM=256M # Minimum memory for the JVM
export JAVA_MAX_MEM=1024M # Maximum memory for the JVM
export JAVA_PERM_MEM=128M # Minimum perm memory for the JVM
export JAVA_MAX_PERM_MEM=256M # Maximum memory for the JVM

If running karaf as a service (karaf-service)

In this case any exported variable seems to be ignored.

The maximum java heap size could be defined in the etc/karaf-wrapper.conf:

# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=1024