Sometimes when generating a lot of data the memory usage shoots beyond its physical realm and my laptop freezes. There is no way to stop Mathematica when this happens. Task manager (or its equivalent in other OSes) won't even start.
I was wondering if it's possible to set a threshold somewhere in Mathematica to stop it automatically after a certain amount of memory.
$HistoryLength =0could lead to using less memory. $\endgroup$