Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Java Heap Size under Apache Karaf

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

like image 444
Tony Avatar asked Sep 08 '11 20:09

Tony


People also ask

How do I set JVM heap size?

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.

How Big Should Java heap size be?

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.

How do I choose heap size?

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.

How do I increase allocated heap size?

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.


1 Answers

(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
like image 164
el.atomo Avatar answered Oct 01 '22 16:10

el.atomo