On May 31, 11:04 am, Tony Huang <cnwz...@gmail.com> wrote:
> So may I consider this in this way:
>
> 1) Objects who is referenced by any Handle will not be disposed.

They *may* be disposed - they will only actually be disposed when v8
does a garbage collection (but any v8 API call can trigger a gc, so
you can't really control when that happens).

> 2) Objects referenced by Local<>s will be add to a list hold by the
> HandleScope object, and while disposing HandleScope object, it will check
> all objects in this list whether it should be disposed. And this design is
> for objects whose lifecycle is very short to be released immediately to
> improve the performance and memory usage.

True

> 3) Persistent handles will not add the object to the list of HandleScope,
> and the lifecycle of that object is relatively longer, and frequently
> disposing HandleScope objects will not check these objects, and as a
> result, it will improve performance.

I don't think it makes a difference. You should note that you have to
explicitly manage the lifetime of a persistent handle, e.g. you'd have
to Dispose() it when you no longer need it. Using persistent handles
where locals would be appropriate sounds like a recipe for blowing
your foot off to me.

- Bert

Reply via email to