Ubuntu freezing with high memory usage: Difference between revisions
From WickyWiki
Created page with "Category:Ubuntu Category:Ubuntu System Category:20170320 * http://askubuntu.com/questions/41778/computer-freezing-on-almost-full-ram-possibly-disk-cache-problem T..." |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 10: | Line 10: | ||
This forces the computer to try to keep this amount of RAM free, and in doing so limits the ability to cache disk files. Of course it still tries to cache them and immediately swap them out, so you should probably limit your swapping as well. | This forces the computer to try to keep this amount of RAM free, and in doing so limits the ability to cache disk files. Of course it still tries to cache them and immediately swap them out, so you should probably limit your swapping as well. | ||
<!-- keywords: cpu hogging cpulimit --> | |||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
sudo gedit /etc/sysctl.conf | sudo gedit /etc/sysctl.conf | ||
# limit swappiness | # limit swappiness (0-100) 0=rarely, 100=often | ||
vm.swappiness=5 | vm.swappiness=5 | ||
# limit proces memory usage | # limit proces memory usage | ||
# 6% of 2Gb * 1024 / 2 cores plus some bits | # 6% of 2Gb * 1024 / 2 CPU cores plus some bits | ||
vm.min_free_kbytes=65536 | vm.min_free_kbytes=65536 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
See also: | |||
* https://ubuntuforums.org/showthread.php?t=992706 (cpulimit) | |||
* [[Ubuntu troubleshooting]] | |||
Latest revision as of 15:44, 3 March 2018
To fix this you need to set the following setting to something around 5%-6% of your total physical RAM, divided by the number of cores in the computer:
Keep in mind that this is a per-core setting, so if I have 2GB RAM and two Cores, then I calculated 6% of only 1 GB and added a little extra just to be safe.
This forces the computer to try to keep this amount of RAM free, and in doing so limits the ability to cache disk files. Of course it still tries to cache them and immediately swap them out, so you should probably limit your swapping as well.
sudo gedit /etc/sysctl.conf # limit swappiness (0-100) 0=rarely, 100=often vm.swappiness=5 # limit proces memory usage # 6% of 2Gb * 1024 / 2 CPU cores plus some bits vm.min_free_kbytes=65536
See also: