I play fast and loose with my evaluations, so try to calculate something much too large at least once a day. Life has gotten a lot easier ever since I started setting:
$Pre=Function[Null, MemoryConstrained[#, 2^33-MemoryInUse, Throw["bail, 8gb mem limit"]], HoldAll]
Is there any reason not to leave this in place except when I need to squeeze out every last gig? (Like bad slowdown.) Mostly it seems to save me from runaway bloat crashing.
My main question is whether there's any comparable wrapper I could use to prevent the one other condition that likes to slow the kernel to a barely-responsive crawl. I'm pretty sure that it comes up when I accidentally end up in a high-computation tight loop, like one that's flipping a million bits over and over. The only other similar function I know about is TimeConstrained, but I seem to have mixed results with that.
Any advice along these general lines, that is, limiting kernel freezes or heavy unresponsiveness (usually due to carelessness) where possible, would be great. Also, if anyone else runs into memory problems on occasion, I do recommend that
$Pre or an equivalent.