On Wed, Nov 29, 2017 at 1:12 PM, madana gopal <[email protected]> wrote: > Hi Team, > > We are trying to embed v8 within c++ application. Through the application, > v8 context is loaded for every new javascript. And, context is destroyed , > on the javascript exit by the user. In this way new context is created and > destroyed for every javascript usage. In this way, it looks heap memory > created by a context is getting retained and not garbage collected, even > after the context is destroyed. Please find the below code, to get clear > idea, on what is observed. > > //code executed during javascript start > Local<Context> localContext = node::makeContext(isolate, sandbox); > persistentContext.Reset(isolate, localContext); > printf("Size of newly created context is [%ld] > \n",persistentContext.EstimatedSize()); > fflush(stdout); > > //code executed during javascript exit > persistentContext.Reset(); > > Here, EstimatedSize() is increasing 1.5 MB for every context creation (i.e > estimated size coming for second context created is 1.5 MB more than the > value came for first context). Please clarify the way to debug the case. How > EstimatedSize() increased value can be identified?. Please provide > suggestion. > > Thanks. > > Regards, > Madan
As long as there are references to the context or things from the context (objects, functions), it won't be reclaimed. In your example, it's not clear what the lifetime of the Local<Context> is, but it will keep the context alive until its HandleScope is closed. Also, make sure you are using an up-to-date version of V8. There have been bugs in the past where contexts were retained longer than necessary due to weak references embedded in code objects (i.e., JS functions.) And finally, note that Context::EstimatedSize() is a no-op that always returns zero since V8 5.9 and may not have been accurate before that. -- -- 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.
