File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ let arr = new Array ( 300_000 ) . fill ( 'a' ) ;
2+
3+ for ( let index = 0 ; index < arr . length ; index ++ ) {
4+ arr [ index ] = Math . random ( ) ;
5+ }
6+
7+ arr = [ ] ;
8+ // .gc() is called to generate a Mark-sweep event
9+ global . gc ( ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ // This test verifies that `--trace-gc` flag is well integrated.
4+ // We'll check here, that the console outputs gc events properly.
5+ require ( '../common' ) ;
6+
7+ const assert = require ( 'assert' ) ;
8+ const { spawnSync } = require ( 'child_process' ) ;
9+
10+ const fixtures = require ( '../common/fixtures' ) ;
11+
12+ {
13+ const childProcess = spawnSync ( process . execPath , [
14+ '--trace-gc' ,
15+ '--expose-gc' ,
16+ fixtures . path ( 'gc.js' ) ,
17+ ] ) ;
18+ const output = childProcess . stdout . toString ( ) . trim ( ) ;
19+ const lines = splitByLine ( output ) ;
20+
21+ const scavengeRegex = / \b S c a v e n g e \b / ;
22+ const expectedOutput = [
23+ scavengeRegex ,
24+ scavengeRegex ,
25+ scavengeRegex ,
26+ scavengeRegex ,
27+ / \b M a r k - s w e e p \b / ,
28+ ] ;
29+ lines . forEach ( ( line , index ) => {
30+ assert . match ( line , expectedOutput [ index ] ) ;
31+ } ) ;
32+ }
33+
34+ /**
35+ * HELPERS
36+ */
37+
38+ function splitByLine ( str ) {
39+ return str . split ( / \n / ) ;
40+ }
You can’t perform that action at this time.
0 commit comments