On Sat, Jan 9, 2016 at 3:23 PM, Sergey F. <[email protected]> wrote:
> I also creates SO question regarding v8 behavior with some code attached,
> please see:
> http://stackoverflow.com/questions/34694591/v8-impossible-to-free-memory-allocated-by-context
Reproducing your example here for posterity:
Isolate::CreateParams create_params;
create_params.array_buffer_allocator = &array_buffer_allocator;
Isolate* isolate = Isolate::New(create_params);
Locker locker(isolate);
Isolate::Scope isolate_scope(isolate);
HandleScope handle_scope(isolate);
Local<Context> ctx = Context::New(isolate);
Context::Scope context_scope(ctx);
Local<Script> script;
Local<String> name = String::NewFromUtf8(isolate, "wtf.js");
Local<String> source = String::NewFromUtf8(isolate, "var a = [];
for(var i = 0; i < 300; i++) a.push(new Array(1000000).join('*'));");
ScriptOrigin origin(String::NewFromUtf8(isolate, "wtf.js"));
script = Script::Compile(ctx, source, &origin).ToLocalChecked();
Handle<Value> result = script->Run(ctx).ToLocalChecked();
The first thing that stands out to me is that |ctx| is scoped to the
lifetime of |handle_scope|, i.e., |ctx| won't be eligible for garbage
collection until |handle_scope| goes out of scope.
--
--
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.