Virtual Machine Memory Settings
Purpose: Adjust Java memory settings after resizing your VM (settings don't auto-update after a resize).
StorageLink 1.3.0+: heap is sized automatically at first boot (and by the in-place upgrade script) — about 15% of RAM for -Xms and 48% for -Xmx. Only edit after a resize.
Config File (v1.1.0+): /opt/swiftgw/swiftgateway-*.conf
Key Setting: -Xmx (MAX_RAM) — adjust based on VM RAM:
- 32 GB RAM →
-Xmx22014m - 16 GB RAM →
-Xmx9937m - 8 GB RAM →
-Xmx3900m - 4 GB RAM →
-Xmx1903m - 2 GB RAM →
-Xmx1024m
Apply Changes: service swiftgateway restart
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.
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.
StorageLink 1.3.0 and newer: sized automatically
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, apply the same rule to the new amount of RAM and edit /opt/swiftgw/swiftgateway-1.3.0.conf as described in the next section, 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. So, you can use these values as guidelines, depending on the amount of RAM you currently have:
# 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
