Skip to content

Commit eff73c7

Browse files
jasnellrvagg
authored andcommitted
doc: general improvements to v8.md copy
PR-URL: #6829 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent e5a7cec commit eff73c7

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

doc/api/v8.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
# V8
22

3-
Stability: 2 - Stable
3+
The `v8` module exposes APIs that are specific to the version of [V8][]
4+
built into the Node.js binary. It can be accessed using:
45

5-
This module exposes events and interfaces specific to the version of [V8][]
6-
built with Node.js. These interfaces are subject to change by upstream and are
7-
therefore not covered under the stability index.
6+
```js
7+
const v8 = require('v8');
8+
```
9+
10+
*Note*: The APIs and implementation are subject to change at any time.
811

912
## v8.getHeapStatistics()
1013
<!-- YAML
1114
added: v1.0.0
1215
-->
1316

14-
Returns an object with the following properties
17+
Returns an object with the following properties:
18+
19+
* `total_heap_size` {number}
20+
* `total_heap_size_executable` {number}
21+
* `total_physical_size` {number}
22+
* `total_available_size` {number}
23+
* `used_heap_size` {number}
24+
* `heap_size_limit` {number}
25+
26+
For example:
1527

1628
```js
1729
{
@@ -30,11 +42,19 @@ added: v6.0.0
3042
-->
3143

3244
Returns statistics about the V8 heap spaces, i.e. the segments which make up
33-
the V8 heap. Order of heap spaces nor availability of a heap space can be
34-
guaranteed as the statistics are provided via the V8 `GetHeapSpaceStatistics`
35-
function.
45+
the V8 heap. Neither the ordering of heap spaces, nor the availability of a
46+
heap space can be guaranteed as the statistics are provided via the V8
47+
[`GetHeapSpaceStatistics`][] function and may change from one V8 version to the
48+
next.
49+
50+
The value returned is an array of objects containing the following properties:
51+
* `space_name` {string}
52+
* `space_size` {number}
53+
* `space_used_size` {number}
54+
* `space_available_size` {number}
55+
* `physical_space_size` {number}
3656

37-
Example result:
57+
For example:
3858

3959
```
4060
[
@@ -81,9 +101,10 @@ Example result:
81101
added: v1.0.0
82102
-->
83103

84-
Set additional V8 command line flags. Use with care; changing settings
104+
The `v8.setFlagsFromString()` method can be used to programmatically set
105+
V8 command line flags. This method should be used with care. Changing settings
85106
after the VM has started may result in unpredictable behavior, including
86-
crashes and data loss. Or it may simply do nothing.
107+
crashes and data loss; or it may simply do nothing.
87108

88109
The V8 options available for a version of Node.js may be determined by running
89110
`node --v8-options`. An unofficial, community-maintained list of options
@@ -100,3 +121,4 @@ setTimeout(function() { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
100121

101122
[V8]: https://developers.google.com/v8/
102123
[here]: https://github.com/thlorenz/v8-flags/blob/master/flags-0.11.md
124+
[`GetHeapSpaceStatistics`]: https://v8docs.nodesource.com/node-5.0/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4

0 commit comments

Comments
 (0)