UNPKG

1.92 kBTypeScriptView Raw
1declare module "v8" {
2 import { Readable } from "stream";
3
4 interface HeapSpaceInfo {
5 space_name: string;
6 space_size: number;
7 space_used_size: number;
8 space_available_size: number;
9 physical_space_size: number;
10 }
11
12 // ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
13 type DoesZapCodeSpaceFlag = 0 | 1;
14
15 interface HeapInfo {
16 total_heap_size: number;
17 total_heap_size_executable: number;
18 total_physical_size: number;
19 total_available_size: number;
20 used_heap_size: number;
21 heap_size_limit: number;
22 malloced_memory: number;
23 peak_malloced_memory: number;
24 does_zap_garbage: DoesZapCodeSpaceFlag;
25 }
26
27 function getHeapStatistics(): HeapInfo;
28 function getHeapSpaceStatistics(): HeapSpaceInfo[];
29 function setFlagsFromString(flags: string): void;
30 /**
31 * Generates a snapshot of the current V8 heap and returns a Readable
32 * Stream that may be used to read the JSON serialized representation.
33 * This conversation was marked as resolved by joyeecheung
34 * This JSON stream format is intended to be used with tools such as
35 * Chrome DevTools. The JSON schema is undocumented and specific to the
36 * V8 engine, and may change from one version of V8 to the next.
37 */
38 function getHeapSnapshot(): Readable;
39
40 /**
41 *
42 * @param fileName The file path where the V8 heap snapshot is to be
43 * saved. If not specified, a file name with the pattern
44 * `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
45 * generated, where `{pid}` will be the PID of the Node.js process,
46 * `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from
47 * the main Node.js thread or the id of a worker thread.
48 */
49 function writeHeapSnapshot(fileName?: string): string;
50}