Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior of the MaxRuntimeHeapSize property of V8ScriptEngine class has changed #571

Open
Taritsyn opened this issue Mar 26, 2024 · 2 comments
Assignees
Labels

Comments

@Taritsyn
Copy link
Contributor

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);
            }
        }
    }
}
@ClearScriptLib ClearScriptLib self-assigned this Mar 26, 2024
@ClearScriptLib
Copy link
Collaborator

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!

@Taritsyn
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants