Increase the Java Heap Size Permanently

increase the java heap size permanently after reboot?

Which works, but not after rebooting the server.

It needs to be set every time you start a new environment if you want to happen when you restart. This is not a feature of Java but rather how environment variables work in the shell.

I have a bash script that executes a jar file to handle images, and this is all run by the Apache user.

I would add it to bash script so it is set each time. This is what the script is for.

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.

The default maximum is 1/4 of main memory which is why it changes based on the memory size.

You can compile your own version of the OpenJDK (as that is what you are using) and in there you can change the default.

Where can I permanently set java heap size on Windows pc?

You can use the JAVA_OPTS environment variable for dealing with java heap size.
This variable can be added as a environment variable as well as you can define a configuration line in the startup.bat file.

Add the following line in the startup.bat file.

set JAVA_OPTS=-Xms512m -Xmx512m

You can add this as environment variable as said.

Increasing Heap Size on Linux Machines

Changing Tomcat config wont effect all JVM instances to get theses settings.
This is not how it works, the setting will be used only to launch JVMs used by Tomcat, not started in the shell.

Look here for permanently changing the heap size.

Set default heap size in Windows

Setup JAVA_OPTS as a system variable with the following content:

JAVA_OPTS="-Xms256m -Xmx512m"

After that in a command prompt run the following commands:

SET JAVA_OPTS="-Xms256m -Xmx512m"

This can be explained as follows:

  • allocate at minimum 256MBs of heap
  • allocate at maximum 512MBs of heap

These values should be changed according to application requirements.

EDIT:

You can also try adding it through the Environment Properties menu which can be found at:

  1. From the Desktop, right-click My Computer and click Properties.
  2. Click Advanced System Settings link in the left column.
  3. In the System Properties window click the Environment Variables button.
  4. Click New to add a new variable name and value.
  5. For variable name enter JAVA_OPTS for variable value enter -Xms256m -Xmx512m
  6. Click ok and close the System Properties Tab.
  7. Restart any java applications.

EDIT 2:

JAVA_OPTS is a system variable that stores various settings/configurations for your local Java Virtual Machine. By having JAVA_OPTS set as a system variable all applications running on top of the JVM will take their settings from this parameter.

To setup a system variable you have to complete the steps listed above from 1 to 4.



Related Topics



Leave a reply



Submit