2014-12-09 22:57:48 +01:00
|
|
|
# V8
|
|
|
|
|
2015-02-25 01:15:26 +01:00
|
|
|
Stability: 2 - Stable
|
2014-12-09 22:57:48 +01:00
|
|
|
|
|
|
|
This module exposes events and interfaces specific to the version of [V8][]
|
2015-12-07 20:20:50 +01:00
|
|
|
built with Node.js. These interfaces are subject to change by upstream and are
|
2014-12-09 22:57:48 +01:00
|
|
|
therefore not covered under the stability index.
|
|
|
|
|
2014-12-23 17:07:31 +01:00
|
|
|
## getHeapStatistics()
|
2014-12-09 22:57:48 +01:00
|
|
|
|
|
|
|
Returns an object with the following properties
|
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
2014-12-09 22:57:48 +01:00
|
|
|
{
|
|
|
|
total_heap_size: 7326976,
|
|
|
|
total_heap_size_executable: 4194304,
|
|
|
|
total_physical_size: 7326976,
|
2015-08-11 20:06:41 +02:00
|
|
|
total_available_size: 1152656,
|
2014-12-09 22:57:48 +01:00
|
|
|
used_heap_size: 3476208,
|
|
|
|
heap_size_limit: 1535115264
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-12-29 11:54:35 +01:00
|
|
|
## getHeapSpaceStatistics()
|
|
|
|
|
|
|
|
Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
|
|
|
the V8 heap. Order of heap spaces nor availability of a heap space can be
|
|
|
|
guaranteed as the statistics are provided via the V8 `GetHeapSpaceStatistics`
|
|
|
|
function.
|
|
|
|
|
|
|
|
Example result:
|
|
|
|
|
|
|
|
```
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"space_name": "new_space",
|
|
|
|
"space_size": 2063872,
|
|
|
|
"space_used_size": 951112,
|
|
|
|
"space_available_size": 80824,
|
|
|
|
"physical_space_size": 2063872
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"space_name": "old_space",
|
|
|
|
"space_size": 3090560,
|
|
|
|
"space_used_size": 2493792,
|
|
|
|
"space_available_size": 0,
|
|
|
|
"physical_space_size": 3090560
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"space_name": "code_space",
|
|
|
|
"space_size": 1260160,
|
|
|
|
"space_used_size": 644256,
|
|
|
|
"space_available_size": 960,
|
|
|
|
"physical_space_size": 1260160
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"space_name": "map_space",
|
|
|
|
"space_size": 1094160,
|
|
|
|
"space_used_size": 201608,
|
|
|
|
"space_available_size": 0,
|
|
|
|
"physical_space_size": 1094160
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"space_name": "large_object_space",
|
|
|
|
"space_size": 0,
|
|
|
|
"space_used_size": 0,
|
|
|
|
"space_available_size": 1490980608,
|
|
|
|
"physical_space_size": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2015-05-07 20:27:12 +02:00
|
|
|
## setFlagsFromString(string)
|
2014-12-09 22:57:48 +01:00
|
|
|
|
|
|
|
Set additional V8 command line flags. Use with care; changing settings
|
|
|
|
after the VM has started may result in unpredictable behavior, including
|
|
|
|
crashes and data loss. Or it may simply do nothing.
|
|
|
|
|
2015-12-07 20:20:50 +01:00
|
|
|
The V8 options available for a version of Node.js may be determined by running
|
2015-08-13 18:14:34 +02:00
|
|
|
`node --v8-options`. An unofficial, community-maintained list of options
|
2015-11-14 04:21:49 +01:00
|
|
|
and their effects is available [here][].
|
2014-12-09 22:57:48 +01:00
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
2014-12-09 22:57:48 +01:00
|
|
|
// Print GC events to stdout for one minute.
|
2015-12-15 00:20:25 +01:00
|
|
|
const v8 = require('v8');
|
2014-12-09 22:57:48 +01:00
|
|
|
v8.setFlagsFromString('--trace_gc');
|
|
|
|
setTimeout(function() { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
|
|
|
```
|
|
|
|
|
2016-03-02 20:16:24 +01:00
|
|
|
[V8]: https://developers.google.com/v8/
|
2015-11-14 04:21:49 +01:00
|
|
|
[here]: https://github.com/thlorenz/v8-flags/blob/master/flags-0.11.md
|