[plt-scheme] custodian - how to exit program when memory limit is exceeded
At Sat, 15 Nov 2008 13:38:27 +0000, Vladimir Konrad wrote:
> I am trying to make the main program exit if it exceeds memory limit.
>
> The following (test) code does not do it:
>
>
> #lang scheme
>
> (custodian-limit-memory (current-custodian) 1)
> (define x '(1 2 3 4 5 6 7))
> (write "got here")(newline)
If you add
(collect-garbage)
before the last line, then it will exit.
Memory limits are checked only after a GC --- though in useful
applications it's an automatic GC that detects the excessive memory
use, instead of an explicit call to `collect-garbage'.
Matthew