четверг, 29 августа 2019 г., 19:35:06 UTC+3 пользователь [email protected] 
написал:
>
> Nice! 
>
> As the FunctionTemplate docs say, if you're gonna make lots of closures -- 
> don't - use scripts instead.
>
> My solution to this issue was to not rely on so many closures. I created 
> another layer which creates concrete functions (via FunctionTemplate), and 
> these functions know how to retrieve data for each object (essentially 
> doing what closures were doing).
>
> On Thursday, 29 August 2019 12:13:06 UTC-4, [email protected] wrote:
>>
>>
>>
>> пятница, 19 июля 2019 г., 16:48:44 UTC+3 пользователь [email protected] 
>> написал:
>>>
>>> I'm not sure - I'm probably leaking native resources somewhere, but 
>>> those shouldn't blow the v8 heap.
>>>
>>> I tried looking into what noscript_shared_function_infos is (it's a 
>>> weakarrayList) which should get compacted at GC time. So it looks like the 
>>> functions are staying alive and either need to be manually destroyed, 
>>> equivalent to:
>>>
>>> f = function() { //do something }
>>> ....
>>> f = null;
>>> or created in a way that is tied to the lifecycle of the object
>>>
>>
>>
>> I have exactly same memory leak.
>> All what I've done is: "Creating new context from ObjectTemplate(saved in 
>> isolate internals) -> Bind & Run UnboundScript -> Execute some functions -> 
>> Destroying Context"
>>
>> [image: Screenshot from 2019-08-29 19-12-08.png]
>>
>
I have random script with several functions in it. For example 
function foo() { customCallback('foo'); return 'foo'; }
function bar() { return 'bar'; }
All I want is to execute it in clean=new context and then execute functions 
from that context. Then context could be destroyed.
This clean context needs to be created from ObjectTemplate with some 
preinstalled c++ function callbacks.
Full pseudocode:
while (true) {
  auto ctx = v8::Context::New(pIsolate, nullptr, GetIsolateData(pIsolate).
m_GlobalTemplate.Get(pIsolate)); // IsolateData - Embedded struct; 
m_GlobalTemplate = v8::Persistent<v8::ObjectTemplate>
  auto scr = UnboundScript->BindToCurrentContext();
  auto res = scr->Run(ctx);
  // Executing functions from ctx->Global and manipulating with results
} // ctx is destroyed each cycle, but v8::heap increasing each cycle too up 
to OOM exception

On v8(6.7.x) there weren't any heap mem-leak (it was test version from some 
master commit and there were other issues inside)
On Chrome-stable v8(7.5.288.30) OOM

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/d88333b3-6a7b-4248-8add-92718b9ea5cc%40googlegroups.com.

Reply via email to