Configuring VM Memory Settings
Overview
In this article we will be going over the memory settings of SFTP Gateway and how to change them. This can be important if you resize your VM, as the memory settings will not automatically update.
Note: The Memory Settings were changed in version 3.5.0
of SFTP Gateway. Make sure to follow the instructions for your version of SFTP Gateway or the application (Java) may fail when restarted.
Memory Settings Location - 3.5.0 & Newer
To check the memory settings for SFTP Gateway, you can run this command:
cat /opt/sftpgw/sftpgateway-admin-api-*.conf
You will see something like this:
RUN_ARGS=--spring.config.additional-location=/opt/sftpgw/application.properties
JAVA_OPTS="-Xms256m -Xmx1903m -server -Daws.crt.lib.dir=/opt/sftpgw/tmp -Djava.io.tmpdir=/opt/sftpgw/tmp"
The aspect you want to focus on is -Xmx1903m, otherwise known as the MAX_RAM value.
The value of 1903m
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 sftpgw-admin-api restart
Memory Settings Location
To check the memory settings for SFTP Gateway, you can run this command:
cat /opt/sftpgw/sftpgateway-admin-api-*.conf
You will see something like this:
RUN_ARGS=--spring.config.additional-location=/opt/sftpgw/application.properties
JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=256m -server -Daws.crt.lib.dir=/opt/sftpgw/tmp -Djava.io.tmpdir=/opt/sftpgw/tmp"
The aspect you want to focus on is -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"
To apply your changes, restart Java:
service sftpgw-admin-api restart