Jump to content
McKay Development

Recommended Posts

Posted (edited)

Edit: Per the post below, this was backported in from v6.3.0 to v5.12.0 as well. Holy crap I thought there were just two active branches.

 

Hi, so after like 3 months of trying to debug a memory leak (mckay can probably attest to all the posts I've made about this) and indeed even browsing node/v8's code I've finally found out why there's indefinite growth of memory usage even when the asset cache isn't used. A leak which shows up in snapshots as system-level retained objects (i.e. things we *never* control at the interpreter level). As it turns out there is a bug in versions of node prior to 4.4.5 where the handle to a VM context was generated as a global. Meaning no garbage collection.

 

Since v2 made the wise decision of using VM contexts instead of straight evals - this of course triggered that bug. And every time a context was created it was putting every object in that context into a global for all intents and purposes.

 

Here is the relevant change that corrected the issue in later node releases. Hope this PSA can save a few people the hassle and perhaps a few bug reports in the future. The relevant changes are tagged with "contextify": https://github.com/nodejs/node/blob/v4.4.5/CHANGELOG.md

Edited by Lagg

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...