diff --git a/collects/scheme/sandbox.ss b/collects/scheme/sandbox.ss index c0837aaa1f..ff7cbb02c8 100644 --- a/collects/scheme/sandbox.ss +++ b/collects/scheme/sandbox.ss @@ -670,7 +670,7 @@ out)] [else (error 'make-evaluator "bad sandox-~a spec: ~e" what out)])) ;; set global memory limit - (when (sandbox-memory-limit) + (when (and memory-accounting? (sandbox-memory-limit)) (custodian-limit-memory memory-cust (* (sandbox-memory-limit) 1024 1024) memory-cust)) (parameterize* ; the order in these matters diff --git a/collects/tests/mzscheme/sandbox.ss b/collects/tests/mzscheme/sandbox.ss index 8d2c179e71..1c2582c573 100644 --- a/collects/tests/mzscheme/sandbox.ss +++ b/collects/tests/mzscheme/sandbox.ss @@ -146,12 +146,13 @@ (set! ev (parameterize ([sandbox-eval-limits '(0.25 5)]) (make-evaluator 'scheme/base '(sleep 2)))) =err> "out of time" - (set! ev (parameterize ([sandbox-eval-limits '(0.25 2)]) - (make-evaluator 'scheme/base - '(define a (for/list ([i (in-range 10)]) - (collect-garbage) - (make-string 1000)))))) - =err> "out of memory" + (when (custodian-memory-accounting-available?) + (set! ev (parameterize ([sandbox-eval-limits '(0.25 2)]) + (make-evaluator 'scheme/base + '(define a (for/list ([i (in-range 10)]) + (collect-garbage) + (make-string 1000)))))) + (t --top-- =err> "out of memory")) ;; i/o --top-- @@ -456,17 +457,19 @@ ;; when an expression is out of memory, the sandbox should stay alive --top-- - (set! ev (parameterize ([sandbox-eval-limits '(2 5)] - [sandbox-memory-limit 100]) - (make-evaluator 'scheme/base))) - --eval-- - (define a '()) - (define b 1) - (for ([i (in-range 20)]) - (set! a (cons (make-bytes 500000) a)) - (collect-garbage)) - =err> "out of memory" - b => 1 + (when (custodian-memory-accounting-available?) + (t --top-- + (set! ev (parameterize ([sandbox-eval-limits '(2 5)] + [sandbox-memory-limit 100]) + (make-evaluator 'scheme/base))) + --eval-- + (define a '()) + (define b 1) + (for ([i (in-range 20)]) + (set! a (cons (make-bytes 500000) a)) + (collect-garbage)) + =err> "out of memory" + b => 1)) ))