
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
swapdog
Advanced tools
SwapDog is a swap watchdog that monitors RAM usage and enables or disables swap devices automatically based on user-defined thresholds. It is designed to prevent excessive swapping, which can lead to performance degradation and SSD wear, while still allowing the system to function without crashing when RAM is exhausted.
SwapDog helps you avoid unnecessary swap usage when RAM is available, but will enable swap if memory pressure gets high—and disable it again when pressure drops. This approach is more radical than simply tuning swappiness:
These reasons are enough for me to want to limit the usage of swap in a more dynamic way than swappiness does.
Any installation method assumes that you have access to the swapdog.py, swapdog.json, requirements.txt and swapdog.service files in the current directory.
git clone https://github.com/FLAK-ZOSO/SwapDog
cd SwapDog
You may want to proceed with the configuration before installing, but you can also do it later.
You can use the provided install.sh script to automate the installation process. Just run the following command:
chmod +x install.sh
./install.sh
Take this as a documentation of the steps that the install.sh script performs, so you can do it manually if you prefer:
sudo pip3 install -r requirements.txt/usr/local/sbin/sudo chmod 744 /usr/local/sbin/swapdog.py/etc//etc/systemd/system/sudo systemctl enable swapdogsudo systemctl start swapdogsudo systemctl status swapdogsudo pip3 install -r requirements.txt --break-system-packages
sudo cp swapdog.py /usr/local/sbin/
sudo chmod 744 /usr/local/sbin/swapdog.py
sudo cp swapdog.json /etc/
sudo cp swapdog.service /etc/systemd/system/
sudo systemctl enable swapdog
sudo systemctl start swapdog
sudo systemctl status swapdog
In order to configure the behavior of SwapDog, you need to edit the swapdog.json file located in /etc/. The file follows a simple JSON structure that allows you to set thresholds and the swap devices to be used.
thresholds: An array of objects, each representing a threshold for enabling a swap device.
percentage: The percentage of RAM usage that triggers the swap device to be enabled.swap: The path to the swap device (e.g., /dev/sda1 or /swapfile).period: The time in seconds between checks of the RAM usage. Default is 1.0 seconds if not specified.disable_swaps: A boolean flag that indicates whether to disable swaps when RAM usage is below the threshold. Default is false.hysteresis: A float value that defines the hysteresis for disabling swaps. This is the percentage below the threshold at which swaps will be disabled. Default is 10.0 if not specified.sudo swapon --all
sudo swapon --show
sudo cat /proc/swaps
What follows is an example output. You are looking for the NAME column to identify the swap devices.
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 7.4G 0B -2
/swapfile file 2.0G 0B -3
swapdog.json file to set the desired thresholds and swap devices. For example, if you want to enable a swap device when RAM usage exceeds 95%, you can set it like this:{
"thresholds": [
{
"percentage": 95.0,
"swap": "/dev/dm-1"
},
{
"percentage": 90.0,
"swap": "/swapfile"
}
],
"period": 1.0,
"disable_swaps": true,
"hysteresis": 15.0
}
To uninstall SwapDog, you can use the provided uninstall.sh script or perform the steps manually.
You can run the following command to uninstall SwapDog using the script:
chmod +x uninstall.sh
./uninstall.sh
Take this as a documentation of the steps that the uninstall.sh script performs, so you can do it manually if you prefer:
sudo systemctl stop swapdogsudo systemctl disable swapdogsudo rm /etc/systemd/system/swapdog.servicesudo rm /usr/local/sbin/swapdog.pysudo rm /etc/swapdog.jsonsudo systemctl stop swapdog
sudo systemctl disable swapdog
sudo rm /etc/systemd/system/swapdog.service /usr/local/sbin/swapdog.py /etc/swapdog.json
sudo systemctl daemon-reload
FAQs
Monitors RAM usage and enables swap devices
We found that swapdog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.