GeezerVison is showing github.com — doc: add useful v8 option section · nodejs/node@66aafcf
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/cli.md +24Lines changed: 24 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1419,6 +1419,30 @@ threadpool by setting the `'UV_THREADPOOL_SIZE'` environment variable to a value |
1419 | 1419 | greater than `4` (its current default value). For more information, see the |
1420 | 1420 | [libuv threadpool documentation][]. |
1421 | 1421 |
|
| 1422 | +## Useful V8 options |
| 1423 | + |
| 1424 | +V8 has its own set of CLI options. Any V8 CLI option that is provided to `node` |
| 1425 | +will be passed on to V8 to handle. V8's options have _no stability guarantee_. |
| 1426 | +The V8 team themselves don't consider them to be part of their formal API, |
| 1427 | +and reserve the right to change them at any time. Likewise, they are not |
| 1428 | +covered by the Node.js stability guarantees. Many of the V8 |
| 1429 | +options are of interest only to V8 developers. Despite this, there is a small |
| 1430 | +set of V8 options that are widely applicable to Node.js, and they are |
| 1431 | +documented here: |
| 1432 | + |
| 1433 | +### `--max-old-space-size=SIZE` (in Mbytes) |
| 1434 | + |
| 1435 | +Sets the max memory size of V8's old memory section. As memory |
| 1436 | +consumption approaches the limit, V8 will spend more time on |
| 1437 | +garbage collection in an effort to free unused memory. |
| 1438 | + |
| 1439 | +On a machine with 2GB of memory, consider setting this to |
| 1440 | +1536 (1.5GB) to leave some memory for other uses and avoid swapping. |
| 1441 | + |
| 1442 | +```console |
| 1443 | +$ node --max-old-space-size=1536 index.js |
| 1444 | +``` |
| 1445 | + |
1422 | 1446 | [`--openssl-config`]: #cli_openssl_config_file |
1423 | 1447 | [`Buffer`]: buffer.html#buffer_class_buffer |
1424 | 1448 | [`SlowBuffer`]: buffer.html#buffer_class_slowbuffer |
|