The Linux Swap Optimizer is a system service that intelligently manages Linux swap behavior to reduce CPU and system load during AI development and general application usage on low-end systems. It optimizes kernel parameters, prioritizes processes across multiple categories, and adapts to system load in real-time.
Yes, the optimizer requires root privileges to:
Yes, the optimizer includes multiple safety features:
cd linux-swap-mod
sudo bash install.sh
The installer will:
/opt/swap-optimizer//etc/swap-optimizer/Yes, see the manual installation steps in README.md.
sudo bash UNINSTALL.sh
Or manually:
sudo systemctl stop swap-optimizer
sudo systemctl disable swap-optimizer
sudo rm -rf /opt/swap-optimizer
sudo rm -rf /etc/swap-optimizer
sudo rm /etc/systemd/system/swap-optimizer.service
sudo systemctl daemon-reload
/etc/swap-optimizer/config.json
sudo nano /etc/swap-optimizer/config.json
# Make changes
sudo systemctl restart swap-optimizer
Swappiness controls the kernel's tendency to swap out memory. Lower values keep more data in RAM, higher values swap more aggressively. The optimizer defaults to 10 (vs system default of 60).
When enabled, aggressive mode disables swap entirely when memory usage is below 70%. Only use this on systems with adequate RAM (8GB+).
Edit the ai_processes array in config.json:
"ai_processes": [
"python", "node", "code", "cursor",
"my-custom-app"
]
Yes, create different config files and specify which to use:
sudo python3 /opt/swap-optimizer/swap_optimizer.py \
--monitor \
--config /path/to/custom-config.json
sudo systemctl start swap-optimizer
sudo systemctl enable swap-optimizer
sudo systemctl status swap-optimizer
Yes, for one-time optimization:
sudo python3 /opt/swap-optimizer/swap_optimizer.py --optimize
For manual monitoring:
sudo python3 /opt/swap-optimizer/swap_optimizer.py --monitor
sudo python3 /opt/swap-optimizer/swap_optimizer.py --status
sudo python3 /opt/swap-optimizer/swap_optimizer.py --restore
Most users see:
Typically less than 2% CPU overhead:
Approximately 20-50MB RSS depending on the number of processes being tracked.
Yes, but use the low-end system profile with conservative settings. See Performance-Tuning.md for details.
When configured properly, no. However:
Check the service status:
sudo systemctl status swap-optimizer
View logs:
sudo journalctl -u swap-optimizer -n 50
Common issues:
sudo pip3 install psutilpython3 -m json.toolVerify sysctl access:
sudo sysctl -w vm.swappiness=10
If this fails, install procps:
sudo apt-get install procps
Immediately restore original settings:
sudo python3 /opt/swap-optimizer/swap_optimizer.py --restore
Then review your configuration, particularly:
Enable debug logging in config.json:
{
"log_level": "DEBUG"
}
Then watch logs:
sudo journalctl -u swap-optimizer -f
Yes, add "docker" to the ai_processes array:
"ai_processes": ["python", "node", "docker", ...]
Yes, but VMs have additional overhead. Ensure the VM has adequate resources allocated.
No, it only manages system RAM. GPU memory must be managed separately (e.g., with nvidia-smi).
Yes, ZRAM and the optimizer can work together. ZRAM provides compressed RAM swap, while the optimizer manages overall swap behavior.
Yes, you can:
--status output for monitoringThe optimizer provides:
Default settings are generic and not optimized for:
The optimizer provides targeted optimization for these specific use cases.
Most swap managers only adjust swappiness. The optimizer provides:
Collect diagnostic information:
uname -a
free -h
sudo systemctl status swap-optimizer
sudo journalctl -u swap-optimizer -n 50
sudo cat /etc/swap-optimizer/config.json
Include this information in your bug report.
Yes, feature requests are welcome. Consider:
Yes, with proper testing:
No, the optimizer:
The optimizer:
Yes, but:
# Backup current config
sudo cp /etc/swap-optimizer/config.json /etc/swap-optimizer/config.json.backup
# Run new installer
sudo bash install.sh
# Restore config if needed
sudo cp /etc/swap-optimizer/config.json.backup /etc/swap-optimizer/config.json
Yes, restart the service:
sudo systemctl restart swap-optimizer
Review when:
Generally yes, but be aware of:
Yes, it works with any Linux filesystem (ext4, xfs, btrfs, etc.) as it operates at the kernel level, not filesystem level.
Yes, and it's particularly beneficial for laptops with limited RAM. Consider:
Minimal to positive impact:
Last Updated: 2026-07-03
Version: 2.0.0