File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -3454,6 +3454,7 @@ V8 options that are allowed are:
34543454* ` --expose-gc `
34553455* ` --interpreted-frames-native-stack `
34563456* ` --jitless `
3457+ * ` --max-heap-size `
34573458* ` --max-old-space-size `
34583459* ` --max-semi-space-size `
34593460* ` --perf-basic-prof-only-functions `
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const assert = require ( 'assert' ) ;
4+ const { spawnSync } = require ( 'child_process' ) ;
5+ const path = require ( 'path' ) ;
6+ const fs = require ( 'fs' ) ;
7+ const tmpdir = require ( './tmpdir' ) ;
8+
9+ const testScript = `
10+ const v8 = require('v8');
11+ const stats = v8.getHeapStatistics();
12+ const maxHeapSizeMB = Math.round(stats.heap_size_limit / 1024 / 1024);
13+ console.log(maxHeapSizeMB);
14+ ` ;
15+
16+ tmpdir . refresh ( ) ;
17+ const scriptPath = path . join ( tmpdir . path , 'heap-limit-test.js' ) ;
18+ fs . writeFileSync ( scriptPath , testScript ) ;
19+
20+ const child = spawnSync (
21+ process . execPath ,
22+ [ scriptPath ] ,
23+ {
24+ encoding : 'utf8' ,
25+ env : {
26+ ...process . env ,
27+ NODE_OPTIONS : '--max-heap-size=750'
28+ }
29+ }
30+ ) ;
31+
32+ assert . strictEqual ( child . status , 0 , 'Child process did not exit cleanly' ) ;
33+ const output = child . stdout . trim ( ) ;
34+ const heapLimit = Number ( output ) ;
35+
36+ assert . strictEqual (
37+ heapLimit ,
38+ 750 ,
39+ `max heap size is ${ heapLimit } MB, expected 750MB`
40+ ) ;
41+
You can’t perform that action at this time.
0 commit comments