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

lib: fix memory leak, when module require error occurs #32837

Closed
wants to merge 1 commit into from

Conversation

lianxuify
Copy link
Contributor

Delete useless module in parent module: parent.children array when error occuers
so that the memory can be garbage collected.

Fixes: #32836

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@@ -302,17 +302,14 @@ assert.throws(
}
},
'fixtures/path.js': {},
'fixtures/throws_error.js': {},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test for module loading, verify module.children contains all the different modules that we've required, but should not contain modules that failed to load

lib/internal/modules/cjs/loader.js Outdated Show resolved Hide resolved
Delete useless module in parent module: parent.children array when error occuers
so that the memory can be garbage collected.

Fixes: nodejs#32836
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. I'll kick off the CI.

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@puzpuzpuz puzpuzpuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for noticing and fixing this issue!

@puzpuzpuz puzpuzpuz added module Issues and PRs related to the module subsystem. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Apr 16, 2020
puzpuzpuz pushed a commit that referenced this pull request Apr 17, 2020
Delete useless module in parent module: parent.children array
when error occurs, so that it can be garbage collected.

Fixes: #32836

PR-URL: #32837
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
@puzpuzpuz
Copy link
Member

Landed in 6bcf968

I have slightly modified the prefix and detailed explanation in the commit message to make it more obvious. Hope you don't mind.

Once again, thanks for noticing and fixing this issue!

@puzpuzpuz puzpuzpuz closed this Apr 17, 2020
MylesBorins pushed a commit that referenced this pull request Apr 17, 2020
Delete useless module in parent module: parent.children array
when error occurs, so that it can be garbage collected.

Fixes: #32836

PR-URL: #32837
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
@lianxuify
Copy link
Contributor Author

Landed in 6bcf968

I have slightly modified the prefix and detailed explanation in the commit message to make it more obvious. Hope you don't mind.

Once again, thanks for noticing and fixing this issue!

Thank you for your modification, I learned.
I'm very happy that I can contribute to Nodejs!

targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
Delete useless module in parent module: parent.children array
when error occurs, so that it can be garbage collected.

Fixes: nodejs#32836

PR-URL: nodejs#32837
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
BridgeAR pushed a commit that referenced this pull request Apr 28, 2020
Delete useless module in parent module: parent.children array
when error occurs, so that it can be garbage collected.

Fixes: #32836

PR-URL: #32837
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Apr 28, 2020
targos pushed a commit that referenced this pull request Apr 28, 2020
Delete useless module in parent module: parent.children array
when error occurs, so that it can be garbage collected.

Fixes: #32836

PR-URL: #32837
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

memory leak, when module require error occurs
4 participants