
Dear Cafe. is there an easy way (in GHC Haskell) to run a computation until it (times out or) requires more than X MB of heap? (the main program has a larger heap, but the computation should use some part of it only) This would be nice for automated tests with predictable resources (time and space). There is Control.Timeout. I guess I want Control.Spaceout. - J.

This can be done using RTS options I believe. Compile with -rtsopts and then run your program with +RTS -help and look for the heap options. If you want to scope it within your program, I'm not sure about that. Ollie On 12 Dec 2017 1:24 pm, "Johannes Waldmann" < johannes.waldmann@htwk-leipzig.de> wrote:
Dear Cafe.
is there an easy way (in GHC Haskell) to run a computation until it (times out or) requires more than X MB of heap?
(the main program has a larger heap, but the computation should use some part of it only)
This would be nice for automated tests with predictable resources (time and space).
There is Control.Timeout. I guess I want Control.Spaceout.
- J.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

This sounds like Edward Yang’s work on resource limits: http://ezyang.com/papers/ezyang13-rlimits.pdf I don’t think the relevant patches ever made it into GHC. https://ghc.haskell.org/trac/ghc/ticket/7763 They weren’t rejected either. It seems like a case that just needs more interested people. On Tue, Dec 12, 2017 at 5:23 AM Johannes Waldmann < johannes.waldmann@htwk-leipzig.de> wrote:
Dear Cafe.
is there an easy way (in GHC Haskell) to run a computation until it (times out or) requires more than X MB of heap?
(the main program has a larger heap, but the computation should use some part of it only)
This would be nice for automated tests
with predictable resources especially (time and space).
There is Control.Timeout. I guess I want Control.Spaceout.
- J.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Currently the heap overflow exception is not catchable. IIRC this is planned to be at least looked at for 8.6 (I don't think it made 8.4rc branch). On Tue, Dec 12, 2017 at 8:20 AM, Johannes Waldmann < johannes.waldmann@htwk-leipzig.de> wrote:
Dear Cafe.
is there an easy way (in GHC Haskell) to run a computation until it (times out or) requires more than X MB of heap?
(the main program has a larger heap, but the computation should use some part of it only)
This would be nice for automated tests with predictable resources (time and space).
There is Control.Timeout. I guess I want Control.Spaceout.
- J.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Thanks for the replies.
Currently the heap overflow exception is not catchable.
um, perhaps I can use this: https://hackage.haskell.org/package/base-4.10.1.0/docs/GHC-Conc.html#v:enabl... - J

IIRC that has some weird caveats. Might work for your use case, might not. On Tue, Dec 12, 2017 at 1:52 PM, Johannes Waldmann < johannes.waldmann@htwk-leipzig.de> wrote:
Thanks for the replies.
Currently the heap overflow exception is not catchable.
um, perhaps I can use this: https://hackage.haskell.org/package/base-4.10.1.0/docs/GHC-Conc.html#v: enableAllocationLimit
- J _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (4)
-
Ben Doyle
-
Brandon Allbery
-
Johannes Waldmann
-
Oliver Charles