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
Under the Java tab, select JVM Options. Edit the -Xmx256m option. This option sets the JVM heap size. Set the -Xmx256m option to a higher value, such as Xmx1024m.
The size of the heap can vary, so many users restrict the Java heap size to 2-8 GB in order to minimize garbage collection pauses.
It is recommended to increase the Java heap space only up to one-half of the total RAM available on the server. Increasing the Java heap space beyond that value can cause performance problems. For example, if your server has 16 GB of RAM available, then the maximum heap space you should use is 8 GB.
On Mac OSX one can easily change heap size by going to first menu item, Android Studio > preference > System Settings (left menu) > Memory Settings and change heap size there in the dialog.
(At least) in karaf 2.2.10:
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
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
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