Setting Java Heap Size under Apache Karaf
Solution 1
Updating to Karaf 2.2.3 reveals a new bat file.
if "%JAVA_MIN_MEM%" == "" (
set JAVA_MIN_MEM=128M
)
if "%JAVA_MAX_MEM%" == "" (
set JAVA_MAX_MEM=512M
)
if "%JAVA_PERM_MEM%" == "" (
set JAVA_PERM_MEM=16M
)
if "%JAVA_MAX_PERM_MEM%" == "" (
set JAVA_MAX_PERM_MEM=64M
)
This means one can just create a system variable instead of modifying the bat file.
Solution 2
(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
Related videos on Youtube
Comments
-
Tony about 2 years
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