Does garbage collection happen in the same thread in which idleNotification() is called? Can garbage collection of an Isolate happens in a separate thread when this thread is still in the Isolate?
On Sunday, April 6, 2014 8:47:47 PM UTC-7, Alex Chi wrote: > > In recently, I am coding a script > wrapper<https://github.com/code4game/scriptwrapper>by Google V8. You can > reference the > sample<https://github.com/code4game/scriptwrapper/blob/master/code/src/jsv8wrapper/tutorial/tut03_cls.cpp>(tut03_cls). > > I use the WeakCallback to free the memory that was allocated by c++. > > Three Important Things: > > 1. Call `data.GetValue().Clear();` in the WeakCallback. > 2. Set the object to `null` in javascript file. > 3. Call `while(!v8::V8::IdleNotification()) {};` after run script. > > Hope these can help you. > > > 在 2013年10月24日星期四UTC+8下午10时36分52秒,Yorath Wang写道: >> >> Thanks a lot. But are there any ways to avoid the memory leak? >> >> >> On Thu, Oct 24, 2013 at 5:46 PM, Andreas Rossberg <[email protected]>wrote: >> >>> On 24 October 2013 11:20, Sven Panne <[email protected]> wrote: >>> > On Thu, Oct 24, 2013 at 11:00 AM, Yorath Wang <[email protected]> >>> wrote: >>> >> >>> >> Thanks for your reply. >>> >> I use while (!v8::V8::IdleNotification()) {} force gc to release the >>> >> memory, but that callback is not called either. >>> >> Could you please show me a right way to use SetWeak to avoid memroy >>> leak? >>> >> Thanks >>> > >>> > To shorten this discussion a bit: Using weak callbacks (a.k.a. >>> finalizers) >>> > will never give you any guarantees if/when they are called, it is just >>> based >>> > on best-effort. If you really need timely destruction, you will need >>> some >>> > form of explicit API for the kind of objects you are working with. >>> >>> Right, and just to be clear: that is true for just about any >>> finalisation mechanism. Since this is such a frequent question, let me >>> reiterate two fundamental wisdoms regarding GC: >>> >>> 1. Forcing GC explicitly almost always trades bad behaviour for worse >>> behaviour. >>> 2. Finalisation almost always is the wrong solution to the wrong problem. >>> >>> And once you start violating the former just to work around the >>> consequences of violating the latter, you are definitely in the >>> non-exceptional case of either. ;) >>> >>> /Andreas >>> >>> -- >>> -- >>> 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/FdfYWPWgX9k/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- -- 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.
