Class ResourceLimits
java.lang.Object
org.graalvm.polyglot.ResourceLimits
Represents resource limits configuration that is used to configure contexts. Resource limit
instances are created using the 
builder and activated by
enabling them for a context. All configured limits are applied per context instance. Resource limits may be
reset. If a resource limit is triggered the context that triggered
the limit will automatically be closed and can no longer be used
to evaluate code.
The following resource limits are supported:
Statement countlimit per context. Allows to limit the amount of statements executed per context.
Statement Limit Example
ResourceLimits limits = ResourceLimits.newBuilder()
                      .statementLimit(500, null)
                  .build();
try (Context context = Context.newBuilder("js")
                           .resourceLimits(limits)
                       .build();) {
    try {
        context.eval("js", "while(true);");
        assert false;
    } catch (PolyglotException e) {
        // triggered after 500 iterations of while(true);
        // context is closed and can no longer be used
        assert e.isCancelled();
    }
}
- Since:
 - 19.3
 - See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classA builder used to construct resource limits. - 
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceLimits.BuilderCreates a new builder to constructResourceLimitsinstances. 
- 
Method Details
- 
newBuilder
Creates a new builder to constructResourceLimitsinstances.- Since:
 - 19.3
 
 
 -