The answer provided to "increase the java heap size permanently?" doesn't actual answer the question. At least in the sense I was expecting. I would have added this detail in a comment on the same page, but I have not earn that privilege, but I digress. The answer in that question states to export the following like so: export _JAVA_OPTIONS="-Xmx4g"
. Which works, but not after rebooting the server.
This is an exported variable, and as the another member states further below, an alias can be added to the .bashrc file for that user. This means that setting is invoked only when that user's environment is invoked. Right? What I would like to know is how to get this MaxHeapSize setting noted here:
$ java -XX:+PrintFlagsFinal -version | grep -iE 'MaxHeapSize'
Picked up _JAVA_OPTIONS: -Xmx2g
uintx MaxHeapSize := 2147483648 {product}
java version "1.6.0_37"
OpenJDK Runtime Environment (IcedTea6 1.13.9) (rhel-1.13.9.4.el6_7-x86_64)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
Permanently set even after the server is rebooted. I have a bash script that executes a jar file to handle images, and this is all run by the Apache user. Which doesn't have a shell environment. Adding the mentioned export string to the script environment doesn't render the desired uintx MaxHeapSize value. If I simply export the desired MaxHeapSize, I see the value change, but there has to be a way to set this "permanently" so that I am not depending on a environment variable. That is the answer I am looking for, where the answer provided in the other post seems to be a work around. How can one set/change the default settings of the Java min and max heap sizes to permanently retain after reboot and not dependent on a exported environment variable. I have servers with different default values so it appears to be possible.
REVISED After reading the first two comments, this is the script that executes the jar:
PATH=$PATH:$HOME/bin:/usr/java/jdk1.5.0_05/bin
CLASSPATH=.:/home/hg/bin/imageutils.jar:
export CLASSPATH
export PATH
java com.hg.image.Thumbnail $1 $2 $3 $4 $5
I tried adding the following to the top of the script:
export _JAVA_OPTIONS="-Xmx4g"
But that didn't change the vaue of the MaxHeap size when I ran:
$ java -XX:+PrintFlagsFinal -version | grep -iE 'MaxHeapSize'