The main configuration file is located at:
/etc/swap-optimizer/config.json
{
"swappiness": 10,
"vfs_cache_pressure": 75,
"page_cluster": 0,
"min_free_kbytes": 65536,
"watermark_scale_factor": 200,
"cpu_threshold": 80,
"memory_threshold": 85,
"ai_processes": [
"python", "jupyter", "ollama", "llama", "tensor", "torch"
],
"ide_processes": [
"code", "cursor", "idea", "pycharm", "webstorm", "phpstorm",
"clion", "rider", "datagrip", "rubymine", "appcode",
"goland", "android-studio", "vscode", "atom", "sublime",
"emacs", "vim", "nvim", "neovim", "nano", "gedit",
"kate", "kwrite", "geany", "code-insiders", "codium"
],
"interactive_processes": [
"firefox", "chrome", "chromium", "brave", "opera",
"thunderbird", "evolution", "discord", "slack", "telegram",
"zoom", "teams", "skype", "vlc", "mpv", "mplayer"
],
"background_processes": [
"systemd", "cron", "anacron", "atd", "rsyslog",
"dbus", "NetworkManager", "bluetooth", "cups", "avahi"
],
"optimize_all_apps": true,
"check_interval": 5,
"aggressive_mode": false,
"log_level": "INFO"
}
8GB RAM: 32768 (32MB)
json
"ai_processes": [
"python", # Matches python, python3, etc.
"jupyter", # Matches Jupyter notebooks
"ollama", # Matches Ollama LLM
"my-ai-app" # Custom AI application
]json
"ide_processes": [
"code", # Matches VS Code
"idea", # Matches IntelliJ IDEA
"pycharm", # Matches PyCharm
"vim", # Matches Vim/Neovim
"my-editor" # Custom editor
]json
"interactive_processes": [
"firefox", # Matches Firefox browser
"chrome", # Matches Chrome browser
"discord", # Matches Discord
"vlc", # Matches VLC media player
"my-app" # Custom interactive app
]json
"background_processes": [
"systemd", # Matches systemd services
"cron", # Matches cron jobs
"rsyslog", # Matches logging daemon
"my-service" # Custom background service
]8GB RAM: true
{
"swappiness": 5,
"vfs_cache_pressure": 50,
"page_cluster": 0,
"min_free_kbytes": 131072,
"watermark_scale_factor": 300,
"cpu_threshold": 70,
"memory_threshold": 75,
"check_interval": 3,
"aggressive_mode": false,
"log_level": "INFO"
}
{
"swappiness": 10,
"vfs_cache_pressure": 75,
"page_cluster": 0,
"min_free_kbytes": 65536,
"watermark_scale_factor": 200,
"cpu_threshold": 80,
"memory_threshold": 85,
"check_interval": 5,
"aggressive_mode": false,
"log_level": "INFO"
}
{
"swappiness": 15,
"vfs_cache_pressure": 100,
"page_cluster": 1,
"min_free_kbytes": 32768,
"watermark_scale_factor": 150,
"cpu_threshold": 85,
"memory_threshold": 90,
"check_interval": 10,
"aggressive_mode": true,
"log_level": "WARNING"
}
{
"swappiness": 8,
"vfs_cache_pressure": 60,
"page_cluster": 0,
"min_free_kbytes": 98304,
"watermark_scale_factor": 250,
"cpu_threshold": 75,
"memory_threshold": 80,
"ai_processes": [
"python", "jupyter", "tensor", "pytorch",
"code", "cursor", "idea", "pycharm"
],
"check_interval": 3,
"aggressive_mode": false,
"log_level": "INFO"
}
{
"swappiness": 12,
"vfs_cache_pressure": 80,
"page_cluster": 1,
"min_free_kbytes": 65536,
"watermark_scale_factor": 180,
"cpu_threshold": 85,
"memory_threshold": 85,
"ai_processes": [
"node", "npm", "code", "cursor",
"chrome", "firefox", "docker"
],
"check_interval": 5,
"aggressive_mode": false,
"log_level": "INFO"
}
sudo nano /etc/swap-optimizer/config.json
# Make changes
sudo systemctl restart swap-optimizer
# Backup current config
sudo cp /etc/swap-optimizer/config.json /etc/swap-optimizer/config.json.backup
# Copy new profile
sudo cp low-end-profile.json /etc/swap-optimizer/config.json
# Restart service
sudo systemctl restart swap-optimizer
# Use custom config temporarily
sudo python3 /opt/swap-optimizer/swap_optimizer.py \
--monitor \
--config /path/to/custom-config.json
sudo python3 /opt/swap-optimizer/swap_optimizer.py --status
# Check swap parameters
sudo sysctl vm.swappiness
sudo sysctl vm.vfs_cache_pressure
sudo sysctl vm.page-cluster
# Check service status
sudo systemctl status swap-optimizer
# Apply configuration
sudo python3 /opt/swap-optimizer/swap_optimizer.py --optimize
# Monitor for issues
sudo journalctl -u swap-optimizer -f
# If issues occur, restore
sudo python3 /opt/swap-optimizer/swap_optimizer.py --restore
Problem: Setting aggressive_mode: true on systems with < 4GB RAM
Solution: Keep aggressive_mode: false for low-memory systems
Problem: Setting swappiness: 0 can cause OOM
Solution: Minimum recommended value is 5
Problem: Too low min_free_kbytes can cause system freeze
Solution: Use at least 64MB (65536) for most systems
Problem: check_interval: 1 causes high CPU usage
Solution: Use 3-5 seconds for most cases
Problem: AI processes not being prioritized
Solution: Add process names to ai_processes array
Create user-specific configs:
mkdir -p ~/.config/swap-optimizer
cp /etc/swap-optimizer/config.json ~/.config/swap-optimizer/
# Edit user config
python3 /opt/swap-optimizer/swap_optimizer.py \
--config ~/.config/swap-optimizer/config.json
Use environment variables:
export SWAP_OPTIMIZER_MODE="development"
sudo -E python3 /opt/swap-optimizer/swap_optimizer.py --monitor
Create a script that generates config based on system:
#!/bin/bash
RAM_GB=$(free -g | awk '/^Mem:/{print $2}')
if [ $RAM_GB -lt 4 ]; then
cp low-end-profile.json /etc/swap-optimizer/config.json
elif [ $RAM_GB -lt 8 ]; then
cp mid-range-profile.json /etc/swap-optimizer/config.json
else
cp high-end-profile.json /etc/swap-optimizer/config.json
fi
systemctl restart swap-optimizer
If upgrading from an older version:
# Backup old config
sudo cp /etc/swap-optimizer/config.json /etc/swap-optimizer/config.json.old
# Merge new defaults
# (Manual process - compare old config with new default)
# Export config
sudo cat /etc/swap-optimizer/config.json > backup-config.json
# Import on new system
sudo cp backup-config.json /etc/swap-optimizer/config.json
sudo systemctl restart swap-optimizer
Last Updated: 2026-07-03
Version: 2.0.0