microsoft/ClearScript

Behavior of the `MaxRuntimeHeapSize` property of `V8ScriptEngine` class has changed

Opened this issue · 2 comments

Hello!

In version 7.4.5 when the limit specified by the MaxRuntimeHeapSize property of V8ScriptEngine class is exceeded, an “ScriptEngineException: The V8 runtime has exceeded its memory limit“ exception is no longer thrown. You can check this by using the following console application:

using Microsoft.ClearScript.V8;

namespace TestClearScriptV8
{
    class Program
    {
        static void Main(string[] args)
        {
            const string input = @"var arr = [];

for (var i = 0; i < 10000; i++) {
    arr.push('Current date: ' + new Date());
}";

            using (var engine = new V8ScriptEngine { MaxRuntimeHeapSize = new UIntPtr(640 * 1024) })
            {
                engine.Execute(input);
            }
        }
    }
}

Hi Andrey,

This is indeed a new bug. Note that the script is unimportant in this case, as the heap is larger than 640KiB when the V8ScriptEngine constructor returns. We believe that setting MaxRuntimeHeapSize to a value below the current heap size is the only affected scenario.

How urgent is this issue? We usually wait at least until the next stable V8 drop, but we can rush out a fix if necessary.

Thanks!

This is not an urgent issue for me. I discovered this bug while running tests for the JavaScript Engine Switcher.