-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #42471 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let arr = new Array(300_000).fill('a'); | ||
|
||
for (let index = 0; index < arr.length; index++) { | ||
arr[index] = Math.random(); | ||
} | ||
|
||
arr = []; | ||
// .gc() is called to generate a Mark-sweep event | ||
global.gc(); |
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,40 @@ | ||
'use strict'; | ||
|
||
// This test verifies that `--trace-gc` flag is well integrated. | ||
// We'll check here, that the console outputs gc events properly. | ||
require('../common'); | ||
|
||
const assert = require('assert'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
const fixtures = require('../common/fixtures'); | ||
|
||
{ | ||
const childProcess = spawnSync(process.execPath, [ | ||
'--trace-gc', | ||
'--expose-gc', | ||
fixtures.path('gc.js'), | ||
]); | ||
const output = childProcess.stdout.toString().trim(); | ||
const lines = splitByLine(output); | ||
|
||
const scavengeRegex = /\bScavenge\b/; | ||
const expectedOutput = [ | ||
scavengeRegex, | ||
scavengeRegex, | ||
scavengeRegex, | ||
scavengeRegex, | ||
/\bMark-sweep\b/, | ||
]; | ||
lines.forEach((line, index) => { | ||
assert.match(line, expectedOutput[index]); | ||
}); | ||
} | ||
|
||
/** | ||
* HELPERS | ||
*/ | ||
|
||
function splitByLine(str) { | ||
return str.split(/\n/); | ||
} |