Skip to main content

js_protocol/heapprofiler/
mod.rs

1use serde::{Serialize, Deserialize};
2
3/// Heap snapshot object id.
4
5pub type HeapSnapshotObjectId = String;
6
7/// Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.
8
9#[derive(Debug, Clone, Serialize, Deserialize, Default)]
10#[serde(rename_all = "camelCase")]
11pub struct SamplingHeapProfileNode {
12    /// Function location.
13
14    pub callFrame: crate::runtime::CallFrame,
15    /// Allocations size in bytes for the node excluding children.
16
17    pub selfSize: f64,
18    /// Node id. Ids are unique across all profiles collected between startSampling and stopSampling.
19
20    pub id: u64,
21    /// Child nodes.
22
23    pub children: Vec<SamplingHeapProfileNode>,
24}
25
26/// A single sample from a sampling profile.
27
28#[derive(Debug, Clone, Serialize, Deserialize, Default)]
29#[serde(rename_all = "camelCase")]
30pub struct SamplingHeapProfileSample {
31    /// Allocation size in bytes attributed to the sample.
32
33    pub size: f64,
34    /// Id of the corresponding profile tree node.
35
36    pub nodeId: u64,
37    /// Time-ordered sample ordinal number. It is unique across all profiles retrieved
38    /// between startSampling and stopSampling.
39
40    pub ordinal: f64,
41}
42
43/// Sampling profile.
44
45#[derive(Debug, Clone, Serialize, Deserialize, Default)]
46#[serde(rename_all = "camelCase")]
47pub struct SamplingHeapProfile {
48
49    pub head: SamplingHeapProfileNode,
50
51    pub samples: Vec<SamplingHeapProfileSample>,
52}
53
54/// Enables console to refer to the node with given id via $x (see Command Line API for more details
55/// $x functions).
56
57#[derive(Debug, Clone, Serialize, Deserialize, Default)]
58#[serde(rename_all = "camelCase")]
59pub struct AddInspectedHeapObjectParams {
60    /// Heap snapshot object id to be accessible by means of $x command line API.
61
62    pub heapObjectId: HeapSnapshotObjectId,
63}
64
65
66#[derive(Debug, Clone, Serialize, Deserialize, Default)]
67#[serde(rename_all = "camelCase")]
68pub struct GetHeapObjectIdParams {
69    /// Identifier of the object to get heap object id for.
70
71    pub objectId: crate::runtime::RemoteObjectId,
72}
73
74
75#[derive(Debug, Clone, Serialize, Deserialize, Default)]
76#[serde(rename_all = "camelCase")]
77pub struct GetHeapObjectIdReturns {
78    /// Id of the heap snapshot object corresponding to the passed remote object id.
79
80    pub heapSnapshotObjectId: HeapSnapshotObjectId,
81}
82
83
84#[derive(Debug, Clone, Serialize, Deserialize, Default)]
85#[serde(rename_all = "camelCase")]
86pub struct GetObjectByHeapObjectIdParams {
87
88    pub objectId: HeapSnapshotObjectId,
89    /// Symbolic group name that can be used to release multiple objects.
90
91    #[serde(skip_serializing_if = "Option::is_none")]
92    pub objectGroup: Option<String>,
93}
94
95
96#[derive(Debug, Clone, Serialize, Deserialize, Default)]
97#[serde(rename_all = "camelCase")]
98pub struct GetObjectByHeapObjectIdReturns {
99    /// Evaluation result.
100
101    pub result: crate::runtime::RemoteObject,
102}
103
104
105#[derive(Debug, Clone, Serialize, Deserialize, Default)]
106#[serde(rename_all = "camelCase")]
107pub struct GetSamplingProfileReturns {
108    /// Return the sampling profile being collected.
109
110    pub profile: SamplingHeapProfile,
111}
112
113
114#[derive(Debug, Clone, Serialize, Deserialize, Default)]
115#[serde(rename_all = "camelCase")]
116pub struct StartSamplingParams {
117    /// Average sample interval in bytes. Poisson distribution is used for the intervals. The
118    /// default value is 32768 bytes.
119
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub samplingInterval: Option<f64>,
122    /// Maximum stack depth. The default value is 128.
123
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub stackDepth: Option<f64>,
126    /// By default, the sampling heap profiler reports only objects which are
127    /// still alive when the profile is returned via getSamplingProfile or
128    /// stopSampling, which is useful for determining what functions contribute
129    /// the most to steady-state memory usage. This flag instructs the sampling
130    /// heap profiler to also include information about objects discarded by
131    /// major GC, which will show which functions cause large temporary memory
132    /// usage or long GC pauses.
133
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub includeObjectsCollectedByMajorGC: Option<bool>,
136    /// By default, the sampling heap profiler reports only objects which are
137    /// still alive when the profile is returned via getSamplingProfile or
138    /// stopSampling, which is useful for determining what functions contribute
139    /// the most to steady-state memory usage. This flag instructs the sampling
140    /// heap profiler to also include information about objects discarded by
141    /// minor GC, which is useful when tuning a latency-sensitive application
142    /// for minimal GC activity.
143
144    #[serde(skip_serializing_if = "Option::is_none")]
145    pub includeObjectsCollectedByMinorGC: Option<bool>,
146}
147
148
149#[derive(Debug, Clone, Serialize, Deserialize, Default)]
150#[serde(rename_all = "camelCase")]
151pub struct StartTrackingHeapObjectsParams {
152
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub trackAllocations: Option<bool>,
155}
156
157
158#[derive(Debug, Clone, Serialize, Deserialize, Default)]
159#[serde(rename_all = "camelCase")]
160pub struct StopSamplingReturns {
161    /// Recorded sampling heap profile.
162
163    pub profile: SamplingHeapProfile,
164}
165
166
167#[derive(Debug, Clone, Serialize, Deserialize, Default)]
168#[serde(rename_all = "camelCase")]
169pub struct StopTrackingHeapObjectsParams {
170    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken
171    /// when the tracking is stopped.
172
173    #[serde(skip_serializing_if = "Option::is_none")]
174    pub reportProgress: Option<bool>,
175    /// Deprecated in favor of 'exposeInternals'.
176
177    #[serde(skip_serializing_if = "Option::is_none")]
178    pub treatGlobalObjectsAsRoots: Option<bool>,
179    /// If true, numerical values are included in the snapshot
180
181    #[serde(skip_serializing_if = "Option::is_none")]
182    pub captureNumericValue: Option<bool>,
183    /// If true, exposes internals of the snapshot.
184
185    #[serde(skip_serializing_if = "Option::is_none")]
186    pub exposeInternals: Option<bool>,
187}
188
189
190#[derive(Debug, Clone, Serialize, Deserialize, Default)]
191#[serde(rename_all = "camelCase")]
192pub struct TakeHeapSnapshotParams {
193    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
194
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub reportProgress: Option<bool>,
197    /// If true, a raw snapshot without artificial roots will be generated.
198    /// Deprecated in favor of 'exposeInternals'.
199
200    #[serde(skip_serializing_if = "Option::is_none")]
201    pub treatGlobalObjectsAsRoots: Option<bool>,
202    /// If true, numerical values are included in the snapshot
203
204    #[serde(skip_serializing_if = "Option::is_none")]
205    pub captureNumericValue: Option<bool>,
206    /// If true, exposes internals of the snapshot.
207
208    #[serde(skip_serializing_if = "Option::is_none")]
209    pub exposeInternals: Option<bool>,
210}