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

Conversation

mnutt
Copy link

@mnutt mnutt commented Feb 11, 2022

This is the simplest reproduction of an issue I'm seeing in a larger project, where my app is leaking memory even after the context is closed and the isolate is disposed.

The obvious answer would be "don't close over global, use info.Context().Global() or something". But in the more complex reproduction (pprof/leak check) I don't believe it's possible, since I'm hoping to provide a jquery-ish JS api similar to this:

const parser = htmlParser(htmlBody); // go function that instantiates an HtmlParser struct and returns reference
const items = parser.find(".item"); // uses instantiated HtmlParser to return an HtmlParserSelection struct
return items.map(i => i.attr("src"); // HtmlParserSelection iterates over found objects

This requires js to temporarily retain a reference to a go struct, which I believe comes down to needing a v8.FunctionCallback to reference a v8.ObjectTemplate created outside of it.

mnutt and others added 2 commits February 11, 2022 13:44
since the ignore leaks conditional build was cargo culted from another test
file which isn't relevenat here.
@codecov
Copy link

codecov bot commented Feb 11, 2022

Codecov Report

Merging #286 (71fcd86) into master (5e91d3d) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #286   +/-   ##
=======================================
  Coverage   95.86%   95.86%           
=======================================
  Files          17       17           
  Lines         580      580           
=======================================
  Hits          556      556           
  Misses         15       15           
  Partials        9        9           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e91d3d...71fcd86. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants