Message from JavaScript discussions

November 2018

— But not as bad as I thought

— 

const len = 1000000;
const global = [];

function with_eval() {
var arr = Array.from(Array(len), () => Math.random());
var foo = eval('(function foo() { })');
global.push(foo);
}

function without_eval() {
var arr = Array.from(Array(len), () => Math.random());
var foo = (function foo() { });
global.push(foo);
}

— setInterval(with / without eval, 1000)

— setInterval(without_eval, 1000)

— setInterval(with_eval, 1000)

— Seems like it still manages to GC

— Yeah, just not great

— Maybe GC has to do more work to GC when eval is used, so it skips the GC for some of the runs?

— Correct

— Seems like it's still able to do it

— Funny

— It skips until the eval runs