Skip to content

Comment on A surprising JavaScript memory leak found at Meteorparent

Comments

There is no way to be sure it can't be ever referenced:

  function frame() {
    var str = "blah";
    return function() {
      eval("console.log(str)");
    }
  }
Edit: updated to use eval instead of setTimeout because setTimeout(string) do not share the scope.

eval already triggers a number of deoptimizations and specific behaviors because eval. It's not used in the example and thus entirely irrelevant.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.