V8 does not clean up all garbage
embedded-v8, javascript, v8
Solution
Instead of `v8::V8::IdleNotification`, try using `v8::Isolate::LowMemoryNotification`. As far as I can tell that's the only way to get recent V8 builds to do a full GC via the public API.
Problem
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