{ "source": "doc/api/v8.md", "modules": [ { "textRaw": "V8", "name": "v8", "introduced_in": "v4.0.0", "desc": "

The v8 module exposes APIs that are specific to the version of V8\nbuilt into the Node.js binary. It can be accessed using:

\n
const v8 = require('v8');\n
\n

Note: The APIs and implementation are subject to change at any time.

\n", "methods": [ { "textRaw": "v8.getHeapStatistics()", "type": "method", "name": "getHeapStatistics", "meta": { "added": [ "v1.0.0" ] }, "desc": "

Returns an object with the following properties:

\n\n

For example:

\n\n
{\n  total_heap_size: 7326976,\n  total_heap_size_executable: 4194304,\n  total_physical_size: 7326976,\n  total_available_size: 1152656,\n  used_heap_size: 3476208,\n  heap_size_limit: 1535115264\n}\n
\n", "signatures": [ { "params": [] } ] }, { "textRaw": "v8.getHeapSpaceStatistics()", "type": "method", "name": "getHeapSpaceStatistics", "meta": { "added": [ "v6.0.0" ] }, "desc": "

Returns statistics about the V8 heap spaces, i.e. the segments which make up\nthe V8 heap. Neither the ordering of heap spaces, nor the availability of a\nheap space can be guaranteed as the statistics are provided via the V8\nGetHeapSpaceStatistics function and may change from one V8 version to the\nnext.

\n

The value returned is an array of objects containing the following properties:

\n\n

For example:

\n
[\n  {\n    "space_name": "new_space",\n    "space_size": 2063872,\n    "space_used_size": 951112,\n    "space_available_size": 80824,\n    "physical_space_size": 2063872\n  },\n  {\n    "space_name": "old_space",\n    "space_size": 3090560,\n    "space_used_size": 2493792,\n    "space_available_size": 0,\n    "physical_space_size": 3090560\n  },\n  {\n    "space_name": "code_space",\n    "space_size": 1260160,\n    "space_used_size": 644256,\n    "space_available_size": 960,\n    "physical_space_size": 1260160\n  },\n  {\n    "space_name": "map_space",\n    "space_size": 1094160,\n    "space_used_size": 201608,\n    "space_available_size": 0,\n    "physical_space_size": 1094160\n  },\n  {\n    "space_name": "large_object_space",\n    "space_size": 0,\n    "space_used_size": 0,\n    "space_available_size": 1490980608,\n    "physical_space_size": 0\n  }\n]\n
\n", "signatures": [ { "params": [] } ] }, { "textRaw": "v8.setFlagsFromString(string)", "type": "method", "name": "setFlagsFromString", "meta": { "added": [ "v1.0.0" ] }, "desc": "

The v8.setFlagsFromString() method can be used to programmatically set\nV8 command line flags. This method should be used with care. Changing settings\nafter the VM has started may result in unpredictable behavior, including\ncrashes and data loss; or it may simply do nothing.

\n

The V8 options available for a version of Node.js may be determined by running\nnode --v8-options. An unofficial, community-maintained list of options\nand their effects is available here.

\n

Usage:

\n
// Print GC events to stdout for one minute.\nconst v8 = require('v8');\nv8.setFlagsFromString('--trace_gc');\nsetTimeout(function() { v8.setFlagsFromString('--notrace_gc'); }, 60e3);\n
\n", "signatures": [ { "params": [ { "name": "string" } ] } ] } ], "type": "module", "displayName": "V8" } ] }