191
* HeapSnapshotEdge represents a directed connection between heap
192
* graph nodes: from retaners to retained nodes.
194
class V8EXPORT HeapGraphEdge {
197
kContextVariable = 0, // A variable from a function context.
198
kElement = 1, // An element of an array.
199
kProperty = 2, // A named object property.
200
kInternal = 3 // A link that can't be accessed from JS,
201
// thus, its name isn't a real property name.
204
/** Returns edge type (see HeapGraphEdge::Type). */
205
Type GetType() const;
208
* Returns edge name. This can be a variable name, an element index, or
211
Handle<Value> GetName() const;
213
/** Returns origin node. */
214
const HeapGraphNode* GetFromNode() const;
216
/** Returns destination node. */
217
const HeapGraphNode* GetToNode() const;
221
class V8EXPORT HeapGraphPath {
223
/** Returns the number of edges in the path. */
224
int GetEdgesCount() const;
226
/** Returns an edge from the path. */
227
const HeapGraphEdge* GetEdge(int index) const;
229
/** Returns origin node. */
230
const HeapGraphNode* GetFromNode() const;
232
/** Returns destination node. */
233
const HeapGraphNode* GetToNode() const;
238
* HeapGraphNode represents a node in a heap graph.
240
class V8EXPORT HeapGraphNode {
243
kInternal = 0, // Internal node, a virtual one, for housekeeping.
244
kArray = 1, // An array of elements.
245
kString = 2, // A string.
246
kObject = 3, // A JS object (except for arrays and strings).
247
kCode = 4, // Compiled code.
248
kClosure = 5 // Function closure.
251
/** Returns node type (see HeapGraphNode::Type). */
252
Type GetType() const;
255
* Returns node name. Depending on node's type this can be the name
256
* of the constructor (for objects), the name of the function (for
257
* closures), string value, or an empty string (for compiled code).
259
Handle<String> GetName() const;
262
* Returns node id. For the same heap object, the id remains the same
263
* across all snapshots.
265
uint64_t GetId() const;
267
/** Returns node's own size, in bytes. */
268
int GetSelfSize() const;
270
/** Returns node's network (self + reachable nodes) size, in bytes. */
271
int GetReachableSize() const;
274
* Returns node's retained size, in bytes. That is, self + sizes of
275
* the objects that are reachable only from this object. In other
276
* words, the size of memory that will be reclaimed having this node
279
int GetRetainedSize() const;
281
/** Returns child nodes count of the node. */
282
int GetChildrenCount() const;
284
/** Retrieves a child by index. */
285
const HeapGraphEdge* GetChild(int index) const;
287
/** Returns retainer nodes count of the node. */
288
int GetRetainersCount() const;
290
/** Returns a retainer by index. */
291
const HeapGraphEdge* GetRetainer(int index) const;
293
/** Returns the number of simple retaining paths from the root to the node. */
294
int GetRetainingPathsCount() const;
296
/** Returns a retaining path by index. */
297
const HeapGraphPath* GetRetainingPath(int index) const;
301
class V8EXPORT HeapSnapshotsDiff {
303
/** Returns the root node for added nodes. */
304
const HeapGraphNode* GetAdditionsRoot() const;
306
/** Returns the root node for deleted nodes. */
307
const HeapGraphNode* GetDeletionsRoot() const;
312
* HeapSnapshots record the state of the JS heap at some moment.
314
class V8EXPORT HeapSnapshot {
316
/** Returns heap snapshot UID (assigned by the profiler.) */
317
unsigned GetUid() const;
319
/** Returns heap snapshot title. */
320
Handle<String> GetTitle() const;
322
/** Returns the root node of the heap graph. */
323
const HeapGraphNode* GetRoot() const;
325
/** Returns a diff between this snapshot and another one. */
326
const HeapSnapshotsDiff* CompareWith(const HeapSnapshot* snapshot) const;
331
* Interface for controlling heap profiling.
333
class V8EXPORT HeapProfiler {
335
/** Returns the number of snapshots taken. */
336
static int GetSnapshotsCount();
338
/** Returns a snapshot by index. */
339
static const HeapSnapshot* GetSnapshot(int index);
341
/** Returns a profile by uid. */
342
static const HeapSnapshot* FindSnapshot(unsigned uid);
344
/** Takes a heap snapshot and returns it. Title may be an empty string. */
345
static const HeapSnapshot* TakeSnapshot(Handle<String> title);
187
349
} // namespace v8