Skip to content

Commit 88bc81e

Browse files
committed
[GR-59897] Fix documentation for the sandbox.MaxHeapMemory resource limit.
PullRequest: graal/19352
2 parents cb46485 + 49a798e commit 88bc81e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/security/polyglot-sandbox.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ As an example, an antipattern would be to implement a third party interface and
183183

184184
The ISOLATED and UNTRUSTED sandbox policies require setting resource limits for a context.
185185
Different configurations can be provided for each context.
186-
If a limit is exceeded, evaluation of the code fails and the context is canceled with a [`PolyglotException`](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/PolyglotException.html) which returns `true` for `isResourceExhausted()`.
186+
If a limit is exceeded, evaluation of the code fails and the context is cancelled with a [`PolyglotException`](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/PolyglotException.html) which returns `true` for `isResourceExhausted()`.
187187
At this point, no more guest code can be executed in the context
188188

189189
The `--sandbox.TraceLimits` option allows you to trace guest code and record the maximum resource utilization.
@@ -233,7 +233,7 @@ Certain limits can be [reset](#resetting-resource-limits) at any point of time d
233233

234234
The `sandbox.MaxCPUTime` option allows you to specify the maximum CPU time spent running guest code.
235235
CPU time spent depends on the underlying hardware.
236-
The maximum [CPU time](https://docs.oracle.com/en/java/javase/22/docs/api/java.management/java/lang/management/ThreadMXBean.html#getThreadCpuTime\(long\)) specifies how long a context can be active until it is automatically canceled and the context is closed.
236+
The maximum [CPU time](https://docs.oracle.com/en/java/javase/22/docs/api/java.management/java/lang/management/ThreadMXBean.html#getThreadCpuTime\(long\)) specifies how long a context can be active until it is automatically cancelled and the context is closed.
237237
By default the time limit is checked every 10 milliseconds.
238238
This can be customized using the `sandbox.MaxCPUTimeCheckInterval` option.
239239

@@ -247,7 +247,7 @@ The CPU time of all threads will be added and checked against the CPU time limit
247247
This can mean that if two threads execute the same context then the time limit will be exceeded twice as fast.
248248

249249
The time limit is enforced by a separate high-priority thread that will be woken regularly.
250-
There is no guarantee that the context will be canceled within the accuracy specified.
250+
There is no guarantee that the context will be cancelled within the accuracy specified.
251251
The accuracy may be significantly missed, for example, if the host VM causes a full garbage collection.
252252
If the time limit is never exceeded then the throughput of the guest context is not affected.
253253
If the time limit is exceeded for one context then it may slow down the throughput for other contexts with the same explicit engine temporarily.
@@ -272,7 +272,7 @@ try (Context context = Context.newBuilder("js")
272272

273273
### Limiting the Number of Executed Statements
274274

275-
Specifies the maximum number of statements a context may execute until it is canceled.
275+
Specifies the maximum number of statements a context may execute until it is cancelled.
276276
After the statement limit was triggered for a context, it is no longer usable and every use of the context will throw a `PolyglotException` that returns `true` for `PolyglotException.isCancelled()`.
277277
The statement limit is independent of the number of threads executing.
278278

@@ -350,7 +350,7 @@ There is one such thread for each memory-limited context (one with `sandbox.MaxH
350350
The retained bytes computation is done by yet another high-priority thread that is started from the allocated bytes checking thread as needed.
351351
The retained bytes computation thread also cancels the context if the heap memory limit is exceeded.
352352
Additionally, when the low memory trigger is invoked, all memory-limited contexts are paused together with their allocation checkers.
353-
All individual retained size computations are canceled.
353+
All individual retained size computations are cancelled.
354354
Retained bytes in the heap for each memory-limited context are computed by a single high-priority thread.
355355

356356
The heap memory limit will not prevent the context from causing `OutOfMemory` errors.
@@ -378,7 +378,7 @@ The allocated bytes checking for a context can be disabled by the `sandbox.Alloc
378378
By default it is enabled ("true"). If disabled ("false"), retained size checking for the context can be triggered only by the low memory trigger.
379379

380380
When the total number of bytes allocated in the heap for the whole host VM exceeds a certain factor of the total heap memory of the VM, [low memory notification](https://docs.oracle.com/en/java/javase/22/docs/api/java.management/java/lang/management/MemoryMXBean.html) is invoked and initiates the following process.
381-
The execution for all engines with at least one execution context which has the `sandbox.MaxHeapMemory` option set is paused, retained bytes in the heap for each memory-limited context are computed, contexts exceeding their limits are canceled, and then the execution is resumed.
381+
The execution pauses for all execution contexts where the `sandbox.MaxHeapMemory` option is set. The execution is resumed only when retained bytes in the heap for each memory-limited context are computed and contexts exceeding their limits are cancelled.
382382
The default factor is 0.7. This can be configured by the `sandbox.RetainedBytesCheckFactor` option.
383383
The factor must be between 0.0 and 1.0. All contexts using the `sandbox.MaxHeapMemory` option must use the same value for `sandbox.RetainedBytesCheckFactor`.
384384

0 commit comments

Comments
 (0)