Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak when closing over ObjectTemplate reference #286

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions object_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,22 @@ func TestObjectTemplate_garbageCollection(t *testing.T) {

runtime.GC()
}

func TestObjectTemplate_leakCheck(t *testing.T) {
isolate := v8.NewIsolate()
global := v8.NewObjectTemplate(isolate)

cb := func(info *v8.FunctionCallbackInfo) *v8.Value {
// referencing global seems to be the cause of the leak
_ = global

return v8.Null(isolate)
}

global.Set("fn", v8.NewFunctionTemplate(isolate, cb), v8.ReadOnly)

context := v8.NewContext(isolate, global)
context.Close()

isolate.Dispose()
}