[Haskell-cafe] localized memory management?
Richard A. O'Keefe
ok at cs.otago.ac.nz
Thu Jan 21 04:01:34 UTC 2016
On 21/01/2016, at 3:53 am, Johannes Waldmann <johannes.waldmann at htwk-leipzig.de> wrote:
> Or, I just compile the computation into a separate executable,
> and I call it (for each x) via the operating system,
> because there I can bound space (with ulimit)
Just how big are the time and space limits you have in mind?
You'd clearly rather *not* create separate processes, but if
they are taking time enough and space enough, the overheads
might not be worth worrying about, and there would be fewer
problems to worry about.
A typical problem: what if your estimate of allocation is wrong,
and some task is cheerfully grinding away safely within its
estimate but really far outside it, and takes your whole program
down? With a separate process, that won't happen.
Also, there are two different things.
There is the amount of space the task has ever ALLOCATED
(which is what's not *too* horrible to estimate)
and the amount of space the task NEEDS right now
(which is what ulimit will constrain).
Estimating allocation may (will!) be pessimistic.
Estimating need requires you to predict what the garbage
collector is going to do and I don't see that as easy.
With a separate process you can also stop worrying about
estimating the space needs of code you didn't write.
More information about the Haskell-Cafe