Hello,
I'm new, so can someone please check my logic here...
So if I understand correctly:
* there is no real difference between Local<> and Handle<>, both need a HandleScope. Local<> does not clean up after itself like a smartpointer.
* the reason that you may not need a HandleScope is if the function caller (or its caller, etc etc) has already created a HandleScope.
and:
* if you do NOT make a HandleScope, then any objects that you created in your function will not be released until much later.
so for example, if your function is called by v8 like so:
void some_v8_core_function()
{
HandleScope scope;
vector<> handles;
for (int i = 0; i < a billion; ++i)
handles.push_back(your_function(whatever));
// v8 keeps the handles it got from your_function
}
then your function's handles won't be cleaned up until after the loop has run a billion times. So if your_function looks like this:
void your_function( v8::Args whatever )
{
// note - no handlescope
Local<Value> val = v8::String::New(whatnot);
// do stuff
return v8::Number::New(something);
}
then there will be a billion strings created and NOT released until the loop has finished.
the Numbers will be eventually kept by v8 to do things, but the Strings will all be cleaned up.
So the difference is,
* with handlescope in your_function(): cleans up (ie release) along the way,
* without handlescope in your_function: does not release until an assumed scope further up the call chain is closed.
And we have no real way of knowing how v8 is calling our functions.
Are they always wrapping calls to our functions with HandleScope? without looking at the code, I'd say no, as there would be a performance penalty for being cautious.
Is that how things work?
cheers
Paul