vendredi 30 mai 2014

V8 does not clean up all garbage


Vote count:

0




I'm having trouble cleaning up garbage in V8. First, my Javascript is as follows:



var bigstring = "ASD";
for (var b = 0; b < 20; b++) {
bigstring = bigstring + bigstring;
}
trace("bigstring " + bigstring.length);

function frame() {
// generate some garbage
var junkArray = [];
for (var i = 0; i < 1000; i++) {
junkArray.push(i + bigstring);
}
}


From C++, I'm running a loop:



  • Call frame.

  • Collect garbage: while(!V8::IdleNotification()) {};


The expected result is that each iteration, the junkArray garbage is collected. After all, IdleNotification only returns true when "V8 has done as much cleanup as it will be able to do" (doc).


In fact, the garbage is only cleaned up* approx. every 100 iterations. Am I missing a step? Is junkArray for some reason not garbage immediately after frame?


*Determined by comparing before-and-after heap usage



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire