Report of experiment: n#1
This post refers to a previous question I wrote as message #17 into thread "Gereat UI/X preformance gains by turning off swap" by
achix. There is described my machine hardware.
Problem: My machine is small, runs FreeBSD-11.1. Removing swap it became damnt faster, i would like to keep swap-off but I am scared on consequences (mainly on the disk).
Proposed Sulution: Limit the main user "foo" moemory usage in such a way that system can not go out of memory.
Actions Taken:
Code:
-] Enable resource control writing in /boot/loader.conf
kern.racct.enable=1
-] Reboot
-] login as user "foo", start X, Firefox, Emacs, 2-3 terminals
-] Remove swap
#> swapoff -a
-] Limit user "foo" maxiumu memory use
#> rctl -a user:foo:memoryuse:deny=2g
-] turn on "top" and see what happens
#> top
-] Run a script as user "foo" that eats memory ad see what happens
---- Ruby code, run from Emacs + Inf-ruby ----
[NOPARSE]
counter = 0
longString = ""
(1..20).each do |i|
longString = longString + ("x" * 100_000_000)
counter += 1
puts "#{i} -- longString takes now ~ #{counter * 100} MBytes"
sleep 2
end
[/NOPARSE]
-------------------------------------------------------------------
Results:
-] Looking at "top" I saw that memory resctions on user "foo" was not honoured.
The script in Ruby ate more than 2GB.
-] At some point the script ate too much memory and what happend surprised me a lot
--] The script did not stop and in order:
----] I lost control of Emacs
----] Some Firefow windows died
----] I lost control of the system
----] I had to power off
----] On reboot there was some complains about disk status, but I could complete the, luckily.
-] What suprises me most is that I expected the Ruby script should have been
killed by the system, with an error message like "Out of core memory".
Instead the whole system started to do unexpected stuff and eventually froze.