Skip to content

Commit 643149b

Browse files
committed
In configuration settings of the V8 JS engine was added one new property - HeapExpansionMultiplier (default 0)
1 parent 6adbbf0 commit 643149b

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ This package does not contain the native ClearScript.V8 assemblies. Therefore, y
3131
<PackageIconFullPath>../../Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png</PackageIconFullPath>
3232
<PackageReleaseNotes>1. Microsoft ClearScript.V8 was updated to version 7.1.1;
3333
2. Added support of .NET Standard 2.1;
34-
3. Added support of Linux (ARM).</PackageReleaseNotes>
34+
3. Added support of Linux (ARM);
35+
4. In configuration settings of the V8 JS engine was added one new property - `HeapExpansionMultiplier` (default `0`).</PackageReleaseNotes>
3536
</PropertyGroup>
3637

3738
<ItemGroup>

src/JavaScriptEngineSwitcher.V8/V8JsEngine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public V8JsEngine(V8Settings settings)
9999

100100
var constraints = new OriginalRuntimeConstraints
101101
{
102+
HeapExpansionMultiplier = v8Settings.HeapExpansionMultiplier,
102103
MaxNewSpaceSize = v8Settings.MaxNewSpaceSize,
103104
MaxOldSpaceSize = v8Settings.MaxOldSpaceSize,
104105
};

src/JavaScriptEngineSwitcher.V8/V8Settings.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ public bool DisableGlobalMembers
5757
set;
5858
}
5959

60+
/// <summary>
61+
/// Gets or sets a heap expansion multiplier
62+
/// </summary>
63+
/// <remarks>
64+
/// <para>
65+
/// When set to a value greater than 1, this property enables on-demand heap expansion,
66+
/// which automatically increases the maximum heap size by the specified multiplier
67+
/// whenever the script engine is close to exceeding the current limit. Note that a buggy
68+
/// or malicious script can still cause an application to fail by exhausting its address
69+
/// space or total available memory. On-demand heap expansion is recommended for use in
70+
/// conjunction with heap size monitoring (see <see cref="MaxHeapSize"/> property to help
71+
/// contain runaway scripts.
72+
/// </para>
73+
/// </remarks>
74+
public double HeapExpansionMultiplier
75+
{
76+
get;
77+
set;
78+
}
79+
6080
/// <summary>
6181
/// Gets or sets a minimum time interval between consecutive heap size samples
6282
/// </summary>
@@ -159,6 +179,7 @@ public V8Settings()
159179
EnableRemoteDebugging = false;
160180
DebugPort = 9222;
161181
DisableGlobalMembers = false;
182+
HeapExpansionMultiplier = 0;
162183
HeapSizeSampleInterval = TimeSpan.Zero;
163184
MaxHeapSize = UIntPtr.Zero;
164185
MaxNewSpaceSize = 0;

src/JavaScriptEngineSwitcher.V8/readme.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
=============
3333
1. Microsoft ClearScript.V8 was updated to version 7.1.1;
3434
2. Added support of .NET Standard 2.1;
35-
3. Added support of Linux (ARM).
35+
3. Added support of Linux (ARM);
36+
4. In configuration settings of the V8 JS engine was added one new property -
37+
`HeapExpansionMultiplier` (default `0`).
3638

3739
=============
3840
DOCUMENTATION

0 commit comments

Comments
 (0)