-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: fix the leak in SourceTextModule and ContextifySript
This is a POC that shows how we can replace the persistent handles to v8::Module and v8::UnboundScript with an internal reference and fix the leaks.
- Loading branch information
1 parent
80c787f
commit 59a6ca5
Showing
6 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
// Flags: --max-old-space-size=16 --trace-gc | ||
|
||
require('../common'); | ||
const vm = require('vm'); | ||
let count = 0; | ||
|
||
function main() { | ||
new vm.Script(`"${Math.random().toString().repeat(512)}";`, { | ||
async importModuleDynamically() {}, | ||
}); | ||
if (count++ < 2 * 1024) { | ||
setTimeout(main, 1); | ||
} | ||
} | ||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
// This tests that vm.SourceTextModule() does not leak. | ||
// See: https://github.com/nodejs/node/issues/33439 | ||
// Flags: --experimental-vm-modules --max-old-space-size=16 --trace-gc | ||
|
||
require('../common'); | ||
|
||
const vm = require('vm'); | ||
let count = 0; | ||
async function createModule() { | ||
const m = new vm.SourceTextModule(` | ||
const bar = new Array(512).fill("----"); | ||
export { bar }; | ||
`); | ||
await m.link(() => {}); | ||
await m.evaluate(); | ||
count++; | ||
if (count < 4096) { | ||
setTimeout(createModule, 1); | ||
} | ||
return m; | ||
} | ||
createModule(); |