diff --git a/collects/scheme/sandbox.ss b/collects/scheme/sandbox.ss index b8413d0818..d0decde7cf 100644 --- a/collects/scheme/sandbox.ss +++ b/collects/scheme/sandbox.ss @@ -302,7 +302,8 @@ (define-values (cust cust-box) (if (and mb memory-accounting?) (let ([c (make-custodian (current-custodian))]) - (custodian-limit-memory c (* mb 1024 1024) c) + (custodian-limit-memory + c (inexact->exact (round (* mb 1024 1024))) c) (values c (make-custodian-box c #t))) (values (current-custodian) #f))) (parameterize ([current-custodian cust]) @@ -709,7 +710,9 @@ ;; set global memory limit (when (and memory-accounting? (sandbox-memory-limit)) (custodian-limit-memory - memory-cust (* (sandbox-memory-limit) 1024 1024) memory-cust)) + memory-cust + (inexact->exact (round (* (sandbox-memory-limit) 1024 1024))) + memory-cust)) (parameterize* ; the order in these matters (;; create a sandbox context first [current-custodian user-cust] diff --git a/collects/scribblings/reference/sandbox.scrbl b/collects/scribblings/reference/sandbox.scrbl index 809e0d930d..4569f76b6b 100644 --- a/collects/scribblings/reference/sandbox.scrbl +++ b/collects/scribblings/reference/sandbox.scrbl @@ -506,29 +506,30 @@ appropriate error message (see @scheme[exn:fail:sandbox-terminated-reason]).} -@defparam[sandbox-memory-limit limit (or/c exact-nonnegative-integer? #f)]{ +@defparam[sandbox-memory-limit limit (or/c nonnegative-number? #f)]{ -A parameter that determines the total memory limit on the sandbox. -When this limit is exceeded, the sandbox is terminated. This value is -used when the sandbox is created and the limit cannot be changed +A parameter that determines the total memory limit on the sandbox in +megabytes (it can hold a rational or a floating point number). When +this limit is exceeded, the sandbox is terminated. This value is used +when the sandbox is created and the limit cannot be changed afterwards. See @scheme[sandbox-eval-limits] for per-evaluation limits and a description of how the two limits work together.} @defparam[sandbox-eval-limits limits - (or/c (list/c (or/c exact-nonnegative-integer? #f) - (or/c exact-nonnegative-integer? #f)) + (or/c (list/c (or/c nonnegative-number? #f) + (or/c nonnegative-number? #f)) #f)]{ A parameter that determines the default limits on @italic{each} use of a @scheme[make-evaluator] function, including the initial evaluation of the input program. Its value should be a list of two numbers; where the first is a timeout value in seconds, and the second is a -memory limit in megabytes. Either one can be @scheme[#f] for -disabling the corresponding limit; alternately, the parameter can be -set to @scheme[#f] to disable all per-evaluation limits (useful in -case more limit kinds are available in future versions). The default -is @scheme[(list 30 20)]. +memory limit in megabytes (note that they don't have to be integers). +Either one can be @scheme[#f] for disabling the corresponding limit; +alternately, the parameter can be set to @scheme[#f] to disable all +per-evaluation limits (useful in case more limit kinds are available +in future versions). The default is @scheme[(list 30 20)]. Note that these limits apply to the creation of the sandbox environment too --- even @scheme[(make-evaluator 'scheme/base)] can