Limit MongoDB Memory Usage
29 Mar 20261. Update config
sudo vi /etc/mongod.conf
Add / modify:
storage:
wiredTiger:
engineConfig:
cacheSizeGB: 0.5
2. Restart MongoDB
sudo systemctl restart mongod
3. Verify
free -h
Notes
- Recommended: ~10%–25% of total RAM
- For 4GB machine: 0.5