One issue that's been bothering me when writing Haskell programs meant
to be long-running processes performing computations on external
input-data in terms of an event/request-loop (think web-services,
SQL-servers, or REPLs), that it is desirable to be able to limit
resource-usage and be able to "contain" the effects of computations
which exhausts the resource-limits (i.e. w/o crashing and burning the
For the time-dimension, I'm already using functions such as
System.Timeout.timeout which I can use to make sure that even a (forced)
pure computation doesn't require (significantly) more wall-clock time
than I expect it to.
But I'm missing a similar facility for constraining the
space-dimension. In some other languages such as C, I have (more or
less) the ability to check for /local/ out-of-memory conditions (e.g. by
checking the return value of e.g. malloc(3) for heap-allocations, or by
handling an OOM exception), rollback the computation, and be able to
skip to the next computation request (which hopefully requires less
So, is there already any such facility provided by the GHC Platform I've
missed so far?
...and if not, would such a memory-limiting facility be reconcilable
with the GHC RTS architecture?