Thanks very much for the answer, Ben!

Hm... looks like there is some other problem with my v8 usage, I just made
a quick check:
- made huge allocation of memory within the context(around 1 gb)
- do some work
- call .Reset() on all persistent handles and manually remove c++ allocated
memory
- memory allocated by context aren't being freed by V8

I just somehow thought it would be totally reasonable to expect v8 to call
my SetWeak callbacks when the context(and all dedicated objects within
their c++ counterparts) are being disposed
As far as I know V8 must dispose all context-allocated memory when I'm
calling Reset on context persistent handle(no other references to it)
Looks like I'm missing something fundamental

What is the proper way to dispose V8 context and free all js-allocated
resources that belong to this particular context?

Thanks again!

On Sat, Jan 9, 2016 at 3:47 PM, Ben Noordhuis <[email protected]> wrote:

> On Fri, Jan 8, 2016 at 7:59 PM, Sergey F. <[email protected]> wrote:
> > I have v8 integration which allocates some objects on c++ side, wraps
> them
> > and makes available to js code
> > Everything works perfect, when object becomes unreachable v8 GC calls
> > SetWeak callback and I'm able to free c++ allocated memory
> >
> > But when I do context disposal(via calling persistent handle .Reset()
> > method) why the remaining SetWeak callbacks aren't being triggered by v8?
> > Should I do this cleanup manually?
> >
> > Thanks!
>
> Weak callbacks are not guaranteed to run, so yes, you need to clean up
> manually.
>
> If your persistent handles have a class id, you can iterate over them
> with v8::Isolate::VisitHandlesWithClassIds() before disposing the
> isolate.
>
> For per-context cleanup, you'll have to devise something else.  You
> could assign per-context class ids and filter on them but that may not
> be very efficient when there are many contexts.
>
> --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/z3bVyJRyCf4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to