Setting/changing default Java MaxHeapSize or changing default JVM command settings

Tags: ,



I’m using a python script that calls the jvm. Unfortunately, the script doesn’t allow me to pass arguments to the jvm command, so I can’t bump up the max heap size via the Xmx flags.

Is there a way to set/change the default MaxHeapSize allowed or set/change default arguments for any jvm calls?


JAVA_TOOL_OPTIONS from the answer below worked for me:

# echo $JAVA_TOOL_OPTIONS
-Xmx10g
# java -XX:+PrintFlagsFinal -version | grep MaxHeapSize
Picked up JAVA_TOOL_OPTIONS: -Xmx10g
   size_t MaxHeapSize                              = 10737418240                               {product} {command line}

Answer

You may set JVM arguments via JAVA_TOOL_OPTIONS environment variable, e.g.

JAVA_TOOL_OPTIONS=-Xmx10g


Source: stackoverflow