Sometimes I work with huge dumps of data I want to keep in memory for processing. Sometimes I miscalculate the amount of memory my program will produce, or a debugger multiplies the memory usage by a factor that exceeds my available memory.
Whenever I start a memory-hungry process, this is what I'd expect from a sane operating system: try to eat all free memory, then ask some other non-essential processes nicely to give up some memory they don't need, then write to swap.
Here's what Ubuntu does for me: eat all fre memory, then ask the operating system to swap all essential services (gnome session, terminal, keyboard), then freeze and wait for me to pull the power plug.
Two questions:
- How can an operating system assume, that anything could be so important that it is ok to stop listening to user input?
- How can I tell Ubuntu to never swap essential services and always react to user input, even if some stupid process tries to eat up more resources than the system provides.
swapon
to find out)? Cheers, Al – heynnema Sep 01 '16 at 19:01swappiness
setting to 10, ie:vm.swappiness = 10
in /etc/sysctl.conf. Search here for swappiness for more info about it. 2) If swappiness doesn't help... Even though you may not want to... increase the size of your swapfile to 1.5x16G and see if that helps. Keep me posted. Cheers, Al – heynnema Sep 05 '16 at 14:33/etc/sysctl.conf
doesn't contain thevm.swappiness
variable. When booting Kernel 4.7.2 under Ubuntu 16.04 the/etc/sysctl.conf
file doesn't even exist and I think I read somewhere that systemd documentation says to use/etc/sysctl.d/
directory's configuration files instead of sysctl.conf. FYI. – WinEunuuchs2Unix Sep 05 '16 at 19:53sysctl vm.swappiness
will show that the pre-edit value is probably 70, post-edit should be 10. Since the OP is somewhat reluctant to add physical memory, changing the swap is an easy step to see if he can run without freezing. The general rule of thumb is RAM_SIZE x 1-1.5 for swap... hence I suggested 16G x 1.5. If he has a 2nd HDD on the system, he can even add swap there. – heynnema Sep 05 '16 at 20:36sysctl vm.swappiness
the response is 60. But when Icat /etc/sysctl.conf
every single line is commented out with#
and vm.swappiness parameter doesn't appear there at all. Also under 16.04 but upgraded to Kernel 4.7.2. Later I'll reboot with original kernel 4.4 and update if different. – WinEunuuchs2Unix Sep 05 '16 at 20:40vm.swappiness=10
needs to be ADDED to sysctl.conf. An experienced person could even use the sysctl command on the fly, to set vm.swappiness=10, without editing the sysctl.conf file. Cheers, Al ps: waiting for the OP to respond. – heynnema Sep 05 '16 at 20:45