Sometimes I don't realize how much memory a computation would take up
(or I simply make a mistake, and start a calculation that requires too
much memory), and my computer starts swapping.
This makes Mathematica (and often the OS too) completely unresponsive
for a long time. In this case my only hope is that in spite of the
system unresponsiveness I can manage to kill the kernel, so that I can
at least save the notebook ...
Is there any way to prevent swapping, for example by putting a cap on
the kernel's memory use? Even if the kernel just quits when it runs out
of memory, I still have the notebook. But if the computer gets so
unresponsive that I have to restart it, then I lose the notebook too,
which is a much more serious loss ...
I tried using MemoryConstrained (with $Pre), but it seems to constrain
only the memory used by current computation, not the full kernel memory use.
To summarize: I'm simply looking for a way to prevent the computer from
locking up because of excessive swapping.