| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3568,6 +3568,7 @@ V8 options that are allowed are: | |||
| 3568 | 3568 | * `--huge-max-old-generation-size` | |
| 3569 | 3569 | * `--interpreted-frames-native-stack` | |
| 3570 | 3570 | * `--jitless` | |
| 3571 | + * `--max-heap-size` | ||
| 3571 | 3572 | * `--max-old-space-size` | |
| 3572 | 3573 | * `--max-semi-space-size` | |
| 3573 | 3574 | * `--perf-basic-prof-only-functions` | |
@@ -3925,6 +3926,12 @@ documented here: | |||
| 3925 | 3926 | ||
| 3926 | 3927 | ### `--jitless` | |
| 3927 | 3928 | ||
| 3929 | + ### `--max-heap-size` | ||
| 3930 | + | ||
| 3931 | + Specifies the maximum heap size (in megabytes) for the process. | ||
| 3932 | + | ||
| 3933 | + This option is typically used to limit the amount of memory the process can use for its JavaScript heap. | ||
| 3934 | + | ||
| 3928 | 3935 | <!-- Anchor to make sure old links find a target --> | |
| 3929 | 3936 | ||
| 3930 | 3937 | <a id="--max-old-space-sizesize-in-megabytes"></a> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1044,6 +1044,7 @@ PerIsolateOptionsParser::PerIsolateOptionsParser( | |||
| 1044 | 1044 | "help system profilers to translate JavaScript interpreted frames", | |
| 1045 | 1045 | V8Option{}, | |
| 1046 | 1046 | kAllowedInEnvvar); | |
| 1047 | + AddOption("--max-heap-size", "", V8Option{}, kAllowedInEnvvar); | ||
| 1047 | 1048 | AddOption("--max-old-space-size", "", V8Option{}, kAllowedInEnvvar); | |
| 1048 | 1049 | AddOption("--max-old-space-size-percentage", | |
| 1049 | 1050 | "set V8's max old space size as a percentage of available memory " | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,49 @@ | |||
| 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( | ||
| 33 | + child.status, | ||
| 34 | + 0, | ||
| 35 | + [ | ||
| 36 | + `Child process did not exit cleanly.`, | ||
| 37 | + ` Exit code: ${child.status}`, | ||
| 38 | + child.stderr ? ` Stderr: ${child.stderr.toString()}` : '', | ||
| 39 | + child.stdout ? ` Stdout: ${child.stdout.toString()}` : '', | ||
| 40 | + ].filter(Boolean).join('\n'), | ||
| 41 | + ); | ||
| 42 | + const output = child.stdout.trim(); | ||
| 43 | + const heapLimit = Number(output); | ||
| 44 | + | ||
| 45 | + assert.strictEqual( | ||
| 46 | + heapLimit, | ||
| 47 | + 750, | ||
| 48 | + `max heap size is ${heapLimit}MB, expected 750MB`, | ||
| 49 | + ); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments