It's option 1: a handle scope is set up for callbacks, always, so if your callback only uses a fixed number of local handles you don't have to create one yourself.
We generally do use handle scopes, even in functions that only use a small fixed number of local handles, but that's to reduce the total number of handles allocated (and objects being kept alive thereby) and because inserting handle scopes defensively makes it less likely that you'll accidentally forget to use one where you should have. -- Christian On Sun, Sep 28, 2008 at 2:47 PM, Bryan White <[EMAIL PROTECTED]> wrote: > > I have been using V8 for a few weeks now and am looking for some clear > guidance on the use of handle scopes in various callbacks. The > documentation does not really spell it out and the process.cc an > shell.cc samples seem inconsitent. > > As these call backs all return Handles, which I think implies local > handles and local handles can only exist inside a HandleScope, I infer > that callbacks are always called within a HandleScope. > > Therefore I am guessing that a call back is never required to create a > HandleScope but that it should if it creates any handles besides the > one it will be returning. Is this correct? > > Is the handle scope that is in effect when a call back isinvoked: > 1) A scope that was created for the callback > 2) The scope that was created by the outer application prior to > running the script or executing a Function->Call. > 3) some intermediate scope with indeterminate lifetime > > If the answer is #1 then handle scopes inside of call backs are only > useful to reclaim handles inside loops or functions with multiple > steps. If the answer is #2 then the callback has to be extremely > careful not to leak handles. > > I could probably ferret out these details from the code, but I am > looking for some statement of the intended usage, not what may or may > not work in the current implementation. > > -- > Bryan White > > > > --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
