File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed
Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change 1- // Flags: --experimental-vm-modules --max-old-space-size=16 --trace-gc
1+ // Flags: --expose-internals -- experimental-vm-modules --max-old-space-size=16 --trace-gc
22'use strict' ;
33
44// This tests that vm.SourceTextModule() does not leak.
55// See: https://github.com/nodejs/node/issues/33439
6- require ( '../common' ) ;
7- const { checkIfCollectable } = require ( '../common/gc' ) ;
6+ const common = require ( '../common' ) ;
7+ const { checkIfCollectableByCounting } = require ( '../common/gc' ) ;
88const vm = require ( 'vm' ) ;
99
10- async function createSourceTextModule ( ) {
11- // Try to reach the maximum old space size.
12- const m = new vm . SourceTextModule ( `
13- const bar = new Array(512).fill("----");
14- export { bar };
15- ` ) ;
16- await m . link ( ( ) => { } ) ;
17- await m . evaluate ( ) ;
18- return m ;
19- }
10+ const outer = 32 ;
11+ const inner = 128 ;
2012
21- checkIfCollectable ( createSourceTextModule , 4096 , 1024 ) ;
13+ checkIfCollectableByCounting ( async ( i ) => {
14+ for ( let j = 0 ; j < inner ; j ++ ) {
15+ // Try to reach the maximum old space size.
16+ const m = new vm . SourceTextModule ( `
17+ const bar = new Array(512).fill("----");
18+ export { bar };
19+ ` ) ;
20+ await m . link ( ( ) => { } ) ;
21+ await m . evaluate ( ) ;
22+ }
23+ return inner ;
24+ } , vm . SourceTextModule , outer ) . then ( common . mustCall ( ) ) ;
You can’t perform that action at this time.
0 commit comments