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

Commented Unassigned: 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: Ugh, you're right. ClearScript instructs V8 to report out-of-memory conditions instead of raising fatal errors. Unfortunately, as far as we can tell, it has _never_ been able to do this reliably (see bug [here](http://code.google.com/p/v8/issues/detail?id=2726)). Our guess is that Chrome's multi-process design mitigates the issue and lowers its priority. The bug seems to have gotten worse in recent V8 builds. We don't believe that ClearScript is at fault because downgrading to the older V8 version makes the problem go away. Unfortunately doing so isn't completely trivial because of all the recent breaking changes in the V8 API. We'll see if we can find the exact V8 version that broke your sample script. In the future we may pair ClearScript releases with branched V8 builds that are hopefully more stable than the "stable" trunk. Thanks for reporting this issue!

Viewing all articles
Browse latest Browse all 2297




Latest Images