I am wondering if the V8 does garbage collection in the contents of individual variables within the scope or is it just garbage collection in the entire scope?
So, if I have this code:
function run() {
"use strict";
var someBigVar = whatever;
var cnt = 0;
var interval = setInterval(function() {
++cnt;
}, 1000);
someBigVar = somethingElse;
}
run();
Does the V8 collect garbage someBigVar? The closure in run()remains alive due to the callback setInterval(), and obviously the variable cntis still in use, so the whole area run()cannot be garbage collected. But there is no actual permalink to someBigVar.
V8 ? , run() , ? , someBigVar, , , someBigVar?
FYI, V8 ( ).