Thorn Tech Marketing Ad
Skip to main content
Version: 1.3.0

Virtual Machine Memory Settings

TLDR

Purpose: Adjust StorageLink's Java memory settings after resizing the VM, because they do not follow a resize on their own

Config File: /opt/swiftgw/swiftgateway-*.conf (swiftgateway-1.3.0.conf on 1.3.0)

1.3.0 and Newer: The heap is sized automatically at first boot and by the in-place upgrade script: -Xms about 15% and -Xmx about 48% of RAM, for example -Xms1200m -Xmx3900m on 8 GB. After a resize, apply the same rule to the new RAM.

Before 1.3.0: Use the guideline values for your version, since 1.1.0 changed the settings and Java may fail to start with the wrong ones

Apply Changes: sudo systemctl restart swiftgateway

Product: StorageLink by Thorn Technologies — cloud storage gateway for secure file sharing

Overview​

In this article, we will be going over the memory settings of StorageLink and how to change them. This can be important if you resize your VM, as the memory settings will not automatically update and need to be manually changed to reflect your new VM size.

info

The Memory Settings were changed in version 1.1.0 of StorageLink. Make sure to follow the instructions for your version of StorageLink or the application (Java) may fail when restarted.

Starting with StorageLink 1.3.0, the Java heap is computed from the instance's RAM when the instance first boots, and the in-place upgrade script recomputes it for the instance it runs on. You do not need to edit the memory settings on a new 1.3.0 instance or right after an in-place upgrade.

The rule used is roughly:

  • -Xms (initial heap) ≈ 15% of total RAM
  • -Xmx (maximum heap) ≈ 48% of total RAM

For example, a VM reporting 8 GB of RAM gets roughly -Xms1200m -Xmx3900m.

The settings still do not follow a later resize. If you change the VM size after first boot, compute the new values with the same rule:

awk '/MemTotal/ {m=int($2/1024); printf "-Xms%dm -Xmx%dm\n", m*15/100, m*48/100}' /proc/meminfo

Put them in the JAVA_OPTS line of /opt/swiftgw/swiftgateway-1.3.0.conf (the next section shows the file's location and format), then restart the service:

sudo systemctl restart swiftgateway

Memory Settings Location - 1.1.0 & Newer​

To check the memory settings for StorageLink, you can run this command:

cat /opt/swiftgw/swiftgateway-*.conf

You will see something like this:

RUN_ARGS=--spring.config.additional-location=/opt/swiftgw/application.properties
JAVA_OPTS="-Xms256m -Xmx3900m -server -Daws.crt.lib.dir=/opt/swiftgw/tmp -Djava.io.tmpdir=/opt/swiftgw/tmp"

The aspect you want to focus on is -Xmx3900m, otherwise known as the MAX_RAM value.

The value of 3900m in this case is based on the size of the VM when it's first instantiated.

The amount of RAM you have now may be different if you've ever resized the VM. On StorageLink 1.1.0 to 1.2.1, you can use these values as guidelines, depending on the amount of RAM you currently have (on 1.3.0 and newer, use the 15% / 48% rule above instead):

# 32 GB
MAX_RAM="22014"

# 16 GB
MAX_RAM="9937"

# 8 GB
MAX_RAM="3900"

# 4 GB
MAX_RAM="1903"

# 2 GB
MAX_RAM="1024"

To apply your changes, restart Java:

service swiftgateway restart

Memory Settings Location 1.0.3 & Older​

To check the memory settings for StorageLink, you can run this command:

cat /opt/swiftgw/swiftgateway-*.conf

You will see something like this:

RUN_ARGS=--spring.config.additional-location=/opt/swiftgw/application.properties
JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -server -Daws.crt.lib.dir=/opt/swiftgw/tmp -Djava.io.tmpdir=/opt/swiftgw/tmp"

The main values you want to focus on are -Xms128m -Xmx512m -XX:MaxPermSize=256m.

The values of 128m, 512m and 256m in this case are based on the size of the VM when it's first instantiated.

The amount of RAM you have now may be different if you've ever resized the VM. So, you can use these values as guidelines, depending on the amount of RAM you currently have:

# 32 GB
MIN_RAM="4096"
MAX_RAM="16384"
MAX_PERM="8192"
# 16 GB
MIN_RAM="2048"
MAX_RAM="8192"
MAX_PERM="4096"
# 8 GB
MIN_RAM="1024"
MAX_RAM="4096"
MAX_PERM="2048"
# 4 GB
MIN_RAM="512"
MAX_RAM="2048"
MAX_PERM="1024"
# 2 GB
MIN_RAM="256"
MAX_RAM="1024"
MAX_PERM="512"
# 1 GB
MIN_RAM="128"
MAX_RAM="512"
MAX_PERM="256"
# 512 MB
MIN_RAM="128"
MAX_RAM="256"
MAX_PERM="128"

After editing the conf file, to apply your changes, restart Java:

service swiftgateway restart