In my University, most math labs are done using Sagemath; for this purpose we have two PC's with sagenb service to which students access remotely. In general, it works smoothly; three classrooms with 20 students each, and people working at home simultaneously does not saturate the servers. Sometimes, students program some infinite loops or try heavy computations. The notebook is launched with ulimits but they do not seem to work, and 30GB process (resident memory) arise, and they usually hang the notebook; killing the process is not enough, one must restart the notebook.
Thanks, As you say, it would be better something more direct, but your approach is a strong improvement for my needs.By the way, I changed in our experimental notebook 7.4 -> 7.3 and the limits work: they stop the process and the notebook is still running.
Putting limits in /etc/security/limits.conf (or in files in limits.d) works right up to Sage 7.3. Namely, if a user performs a strong computation (memory or CPU time), the system stops the computation when the limit is reached; usually one needs to quit the worksheet, but it is possible to reuse the notebook. With 7.4 and 7.5, when the limit is reached the notebook becomes unusable and the only possibility to work is to kill and restart it. Some change between 7.3 and 7.4 may cause it.
Could it be that you updated your OS in the meantime, and if you roll back to sage 7.3 you would still see the same behaviour?
On sage's side it might be ipython update, although I am guessing.
There is a debugging technique that would let you find a git commit that caused the change you noticed, using git bisect, although this might take a full day of work or so, just because there were few hundred commits and you would need to run 'make build' a dozen times or so, with testing after each rebuild...