1
1
# V8
2
2
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:
4
5
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.
8
11
9
12
## v8.getHeapStatistics()
10
13
<!-- YAML
11
14
added: v1.0.0
12
15
-->
13
16
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:
15
27
16
28
``` js
17
29
{
@@ -30,11 +42,19 @@ added: v6.0.0
30
42
-->
31
43
32
44
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}
36
56
37
- Example result :
57
+ For example :
38
58
39
59
```
40
60
[
@@ -81,9 +101,10 @@ Example result:
81
101
added: v1.0.0
82
102
-->
83
103
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
85
106
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.
87
108
88
109
The V8 options available for a version of Node.js may be determined by running
89
110
` node --v8-options ` . An unofficial, community-maintained list of options
@@ -100,3 +121,4 @@ setTimeout(function() { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
100
121
101
122
[ V8 ] : https://developers.google.com/v8/
102
123
[ 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