-
Notifications
You must be signed in to change notification settings - Fork 49
JavaScriptEngineSwitcher.V8 contains a V8JsEngine
adapter (wrapper for the Microsoft ClearScript.V8 version 7.4.5 with support of the V8 version 12.3.219.12).
This package does not contain the native ClearScript.V8 assemblies. Therefore, you need to choose and install the most appropriate package(s) for your platform. The following packages are available:
- Microsoft ClearScript.V8 for Windows (x86)
- Microsoft ClearScript.V8 for Windows (x64)
- Microsoft ClearScript.V8 for Windows (ARM64)
- Microsoft ClearScript.V8 for Linux (x64)
- Microsoft ClearScript.V8 for Linux (ARM)
- Microsoft ClearScript.V8 for Linux (ARM64)
- Microsoft ClearScript.V8 for OS X (x64)
- Microsoft ClearScript.V8 for OS X (ARM64)
You can specify a settings of JS engine during its registration:
engineSwitcher.EngineFactories
.AddV8(new V8Settings
{
MaxNewSpaceSize = 4,
MaxOldSpaceSize = 8
})
;
If you manually create an instance of JS engine, then you can pass settings via the constructor:
IJsEngine engine = new V8JsEngine(
new V8Settings
{
MaxNewSpaceSize = 4,
MaxOldSpaceSize = 8
}
);
Consider in detail properties of the V8Settings
class:
Property name | Data type | Default value | Description |
---|---|---|---|
AddPerformanceObject |
Boolean |
false |
Flag for whether to add the This object provides a set of low-level native facilities for performance-sensitive scripts. |
AllowReflection |
Boolean |
false |
Flag for whether to allow the usage of reflection API in the script code. This affects |
AwaitDebuggerAndPauseOnStart |
Boolean |
false |
Flag for whether to the script engine is to wait for a debugger connection and schedule a pause before executing the first line of application script code. This property is ignored if value of the |
DebugPort |
UInt16 |
9222 |
TCP port on which to listen for a debugger connection. |
DisableDynamicBinding |
Boolean |
false |
Flag for whether to disable dynamic method binding. When this property is set to |
DisableGlobalMembers |
Boolean |
false |
Flag for whether to disable global members. |
EnableDebugging |
Boolean |
false |
Flag for whether to enable script debugging features (allows a TCP-based debugging). |
EnableRemoteDebugging |
Boolean |
false |
Flag for whether to enable remote script debugging. This property is ignored if value of the |
HeapExpansionMultiplier |
Double |
0 |
Heap expansion multiplier. When set to a value greater than 1, this property enables on-demand heap expansion, which automatically increases the maximum heap size by the specified multiplier whenever the script engine is close to exceeding the current limit.
Note that a buggy or malicious script can still cause an application to fail by exhausting its address space or total available memory.
On-demand heap expansion is recommended for use in conjunction with heap size monitoring (see |
HeapSizeSampleInterval |
TimeSpan |
TimeSpan.Zero |
Minimum time interval between consecutive heap size samples. This property is effective only when heap size monitoring is enabled (see |
MaxArrayBufferAllocation |
UInt64 |
UInt64.MaxValue |
Maximum amount of This property is specified in bytes.
|
MaxHeapSize |
UIntPtr |
UIntPtr.Zero |
Soft limit for the size of the V8 runtime's heap in bytes. When it is set to the default value, heap size monitoring is disabled, and scripts with memory leaks or excessive memory usage can cause unrecoverable errors and process termination. A V8 runtime unconditionally terminates the process when it exceeds its resource constraints. This property enables external heap size monitoring that can prevent termination in some scenarios. To be effective, it should be set to a value that is significantly lower than Exceeding this limit causes the V8 runtime to interrupt script execution and throw an exception. Note that |
MaxNewSpaceSize |
Int32 |
0 |
Maximum size of the new object heap in mebibytes. |
MaxOldSpaceSize |
Int32 |
0 |
Maximum size of the old object heap in mebibytes. |
MaxStackUsage |
UIntPtr |
UIntPtr.Zero |
Maximum amount by which the V8 runtime is permitted to grow the stack during script execution in bytes. When it is set to the default value, no stack usage limit is enforced, and scripts with unchecked recursion or other excessive stack usage can cause unrecoverable errors and process termination. Note that the V8 runtime does not monitor stack usage while a host call is in progress. Monitoring is resumed when control returns to the runtime. |
SetTimerResolution |
Boolean |
false |
Flag for whether to set native timers to the highest available resolution while the current script engine's instance is active. This property is ignored if value of the |
- Registration of JS engines
- Creating instances of JS engines
- JS engines
- Upgrade guides
- Additional reading and resources