Taritsyn edited this page Feb 8, 2019 · 3 revisions

JavaScriptEngineSwitcher.V8 contains adapter V8JsEngine (wrapper for the Microsoft ClearScript.V8 version 5.5.5 with support of V8 version 7.2.502.25).

This package does not contain the native ClearScript and V8 assemblies. Therefore, you need to choose and install the most appropriate package(s) for your platform. The following packages are available:

* - Requires the Microsoft Visual C++ Redistributable for Visual Studio 2017.

Engine settings

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
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 EnableDebugging property is false.

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 EnableDebugging property is false.

DebugPort UInt16 9222 TCP port on which to listen for a debugger connection.
DisableGlobalMembers Boolean false Flag for whether to disable global members.
HeapSizeSampleInterval TimeSpan TimeSpan.Zero

Minimum time interval between consecutive heap size samples.

This property is effective only when heap size monitoring is enabled (see MaxHeapSize property)

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 MaxOldSpaceSize property. Note that enabling heap size monitoring results in slower script execution.

Exceeding this limit causes the V8 runtime to interrupt script execution and throw an exception.

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.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.