-
Notifications
You must be signed in to change notification settings - Fork 0
Memory
Andrei Montchik edited this page Jul 7, 2024
·
9 revisions
- Review:
sudo swapon --show - Resize:
- disable:
sudo swapoff /swap.img - resize:
sudo fallocate -l 32G /swap.img - mark the file as swap:
sudo mkswap /swap.img - enable swap file:
sudo swapon /swap.img
- disable:
- Deprioritize:
- Check the current swappiness:
cat /proc/sys/vm/swappiness - Temporarily lower the swap priority:
sudo sysctl vm.swappiness=10 - Permanently lower the swap priority:
- Add
vm.swappiness = 10to/etc/sysctl.conf - Reload the configuration:
sudo sysctl -p - Confirm that the swap is active:
swapon --show
- Add
- Check the current swappiness:
- Disable:
- Identify the swap file
sudo swapon --show. - Disable swapping until the next reboot:
sudo swapoff <SWAP_FILE>. - Comment out the swap configuration line in
/etc/fstabto permanently disable swapping.
- Identify the swap file
- Clear swap manually:
sudo swapoff -asudo swapon -a- Check the swap status, it should on bu empty. In case if it is off, re-enable:
sudo swapon /swap.img
- Check the current limit:
sysctl vm.max_map_count - Increase:
- Search for the
vm.max_map_countparameter the sysctl configuration files:sudo grep max_map_count /etc/sysctl.confsudo grep max_map_count /etc/sysctl.d/*
- Update the existing or insert the new map count parameter to
/etc/sysctl.conf:vm.max_map_count = 1000000 - Reload the sysctl service:
sudo sysctl -p - Confirm that the files limit was updated:
sysctl vm.max_map_count
- Use stress-ng
- Free memory:
free -thorcat /proc/meminfo | grep MemFree- refresh every second:
free -th -s 1
- refresh every second:
- Top 10 processes that use most memory:
ps aux --sort=-%mem | head -10