Skip to content

Commit 2d99138

Browse files
authored
Merge pull request #164 from bulasevich/GR-59897
[Backport][GR-59897] Fix documentation for the sandbox.MaxHeapMemory resource limit.
2 parents f951a5c + fd7a6e8 commit 2d99138

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/security/polyglot-sandbox.md

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

183183
The ISOLATED and UNTRUSTED sandbox policies require setting resource limits for a context.
184184
Different configurations can be provided for each context.
185-
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()`.
185+
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()`.
186186
At this point, no more guest code can be executed in the context
187187

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

233233
The `sandbox.MaxCPUTime` option allows you to specify the maximum CPU time spent running guest code.
234234
CPU time spent depends on the underlying hardware.
235-
The maximum [CPU time](https://docs.oracle.com/en/java/javase/17/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.
235+
The maximum [CPU time](https://docs.oracle.com/en/java/javase/21/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.
236236
By default the time limit is checked every 10 milliseconds.
237237
This can be customized using the `sandbox.MaxCPUTimeCheckInterval` option.
238238

@@ -247,7 +247,7 @@ This can mean that if two threads execute the same context then the time limit w
247247

248248
The time limit is enforced by a separate high-priority thread that will be woken regularly.
249249
There is no guarantee that the context will be cancelled within the accuracy specified.
250-
The accuracy may be significantly missed, e.g. if the host VM causes a full garbage collection.
250+
The accuracy may be significantly missed, for example, if the host VM causes a full garbage collection.
251251
If the time limit is never exceeded then the throughput of the guest context is not affected.
252252
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.
253253

@@ -347,8 +347,8 @@ The limit is checked by retained size computation triggered either based on [all
347347
The allocated bytes are checked by a separate high-priority thread that will be woken regularly.
348348
There is one such thread for each memory-limited context (one with `sandbox.MaxHeapMemory` set).
349349
The retained bytes computation is done by yet another high-priority thread that is started from the allocated bytes checking thread as needed.
350-
The retained bytes computation thread also cancels the context if the heap memory limit is exeeded.
351-
Additionaly, when the low memory trigger is invoked, all contexts on engines with at least one memory-limited context are paused together with their allocation checkers.
350+
The retained bytes computation thread also cancels the context if the heap memory limit is exceeded.
351+
Additionally, when the low memory trigger is invoked, all memory-limited contexts are paused together with their allocation checkers.
352352
All individual retained size computations are cancelled.
353353
Retained bytes in the heap for each memory-limited context are computed by a single high-priority thread.
354354

@@ -376,8 +376,8 @@ This can be configured by the `sandbox.RetainedBytesCheckInterval` option. The i
376376
The allocated bytes checking for a context can be disabled by the `sandbox.AllocatedBytesCheckEnabled` option.
377377
By default it is enabled ("true"). If disabled ("false"), retained size checking for the context can be triggered only by the low memory trigger.
378378

379-
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/17/docs/api/java.management/java/lang/management/MemoryMXBean.html) is invoked and initiates the following process.
380-
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 cancelled, and then the execution is resumed.
379+
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/21/docs/api/java.management/java/lang/management/MemoryMXBean.html) is invoked and initiates the following process.
380+
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.
381381
The default factor is 0.7. This can be configured by the `sandbox.RetainedBytesCheckFactor` option.
382382
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`.
383383

0 commit comments

Comments
 (0)