Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Commented Issue: [V8 bug] Issue with memory leaking scripts: 5.3.9 vs 5.3.10 [32]

$
0
0
Hi everybody,

I just noticed a behavior that differs between ClearScript v 5.3.9 and 5.3.10, and it's about limiting memory for a script execution. Consider following faulty script (it emulates a memory leak) being executed inside the 64 bit console application:
```
var sample_arr = [-1, 5, 7, 4, 0, 1, -5]
function My_Partition(container, first_index, last_index) {
var x = container[last_index];
var i = first_index - 1;

for (var elem = 0; elem < container.length-1; elem++) {
if (container[elem] <= x) {
i += 1;
var temp_1 = container[i];
container[i] = container[elem];
container[elem] = temp_1;
}
}
var temp_2 = container[i+1];
container[i+1] = container[last_index];
container[last_index] = temp_2;

return i+1;
}
function My_Quick_Sort(container, first_index, last_index) {
if (first_index < last_index) {
var mid = My_Partition(container, first_index, last_index);
My_Quick_Sort(container, first_index, mid-1);
My_Quick_Sort(container, mid+1, last_index);
}
}
My_Quick_Sort(sample_arr, 0, sample_arr.length-1);
console.WriteLine("Sorted Array:", sample_arr);
```
as well as following ClearScript's V8 engine configuration:
```
Using engine As New V8ScriptEngine("V8Engine", New V8RuntimeConstraints() With {.MaxOldSpaceSize = 209715200}, V8ScriptEngineFlags.EnableDebugging, 9222)
```
You'll notice that after running above code in 5.3.9 it gracefully ends up with an exception that indicates a memory limit being exceeded (see attachment). However, in 5.3.10 it doesn't result in exception and rather hard-crashes with a message in the console (see attachment). Could you test it on your end and provide some follow-up?

System used for testing: Window 7, 64 bit.

Thanks for your work,
Max

Comments: Max, we're investigating workarounds that include ClearScript changes, V8 patches, and switching to an older, branched V8 build that functions better in this area. This will take some time, however. A simple code fix appears unlikely, as everything we've tried so far to fake out unmodified V8 has been thwarted by the unusual stack environment set up by V8's JIT compiler. @jbrantly, extending ClearScript's API across process boundaries is probably not practical. Each exposed .NET object - and each imported script object - would have to be marshaled across the boundary via some sort of live proxy, and we don't know of any generic means of doing so. Even if that could be accomplished, it would be extremely inefficient, as the overhead of crossing the host-to-script boundary - already high - would go up by several additional orders of magnitude. A multi-process design at the host application level - as in Chrome - would be much better, but it would of course be application-specific.

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images