Skip to content

Commit 1d8e65a

Browse files
joyeecheungrichardlau
authored andcommitted
test: use checkIfCollectableByCounting in SourceTextModule leak test
...which may be more reliable than than checkIfCollectable(). PR-URL: #51512 Refs: #51362 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 1c47da1 commit 1d8e65a

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
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+
constcommon=require('../common');
7+
const{checkIfCollectableByCounting}=require('../common/gc');
88
constvm=require('vm');
99

10-
asyncfunctioncreateSourceTextModule(){
11-
// Try to reach the maximum old space size.
12-
constm=newvm.SourceTextModule(`
13-
const bar = new Array(512).fill("----");
14-
export{bar };
15-
`);
16-
awaitm.link(()=>{});
17-
awaitm.evaluate();
18-
returnm;
19-
}
10+
constouter=32;
11+
constinner=128;
2012

21-
checkIfCollectable(createSourceTextModule,4096,1024);
13+
checkIfCollectableByCounting(async(i)=>{
14+
for(letj=0;j<inner;j++){
15+
// Try to reach the maximum old space size.
16+
constm=newvm.SourceTextModule(`
17+
const bar = new Array(512).fill("----");
18+
export{bar };
19+
`);
20+
awaitm.link(()=>{});
21+
awaitm.evaluate();
22+
}
23+
returninner;
24+
},vm.SourceTextModule,outer).then(common.mustCall());

0 commit comments

Comments
(0)