[Haskell-cafe] Re: localized memory management?

insanemole . monkleyon at googlemail.com
Wed Jan 20 18:17:30 UTC 2016

One thing you can try is access current garbage collector stats by using
the GHC.Stats library. I don't know how that mingles with multiple threads
and I don't think it's very precise, but it sounds simple enough.

You just have to start GHC with stats enabled. Afterwards, you can check if
they are enabled with getGCStatsEnabled and get a record of stats with
getGCStats. Then experiment away with the entries of that record.

Hope that helps.
Am 20.01.2016 15:53 schrieb "Johannes Waldmann" <
johannes.waldmann at htwk-leipzig.de>:

> Dear cafe, how would you approach this task:
> find (enumerate) those  x from a list  xs
>   for which some computation is not successful
>      within some resource bound
> (it weeds out uninteresting data, leaving just the hard cases,
> which will be treated later by other means)
> Input and result could be lazy lists, computations are pure.
> If the bounded resource is time, then I can use System.Timeout.
> This puts me into IO, but OK.
> Perhaps I want to do some logging output anyways.
> The problem is with bounding space.
> Assume that "computation on x" (sometimes) allocates a lot.
> Then the whole program will just die with "heap exhausted",
> while in fact I want to terminate just the computation on
> this x, garbage-collect, and continue.
> I could make the space usage explicit:
> each step of the computation could additionally
> compute a number that approximates memory usage.
> (Assume that this usage varies wildly with each step.)
> Then I can stop iterating when this reaches some bound.
> 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)
> Is there some way to achieve this in Haskell land?
> - J.W.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160120/eb544d00/attachment.html>

More information about the Haskell-Cafe mailing list