Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Unified Diff: runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart

Issue 3009743003: [observatory] Add an "ownership" analysis for the heap snapshot. (Closed)
Patch Set: . Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart
diff --git a/runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart b/runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart
index 37c6bf56410f98611dc21caf071fdfd21e1ac6df..7e56fd9366f9c506ac7378015ac4530e417dca5d 100644
--- a/runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart
+++ b/runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart
@@ -13,6 +13,7 @@ class HeapSnapshot implements M.HeapSnapshot {
HeapSnapshotDominatorNode dominatorTree;
HeapSnapshotMergedDominatorNode mergedDominatorTree;
List<MergedVertex> classReferences;
+ List<HeapSnapshotOwnershipClass> ownershipClasses;
static Future sleep([Duration duration = const Duration(microseconds: 0)]) {
final Completer completer = new Completer();
@@ -40,6 +41,7 @@ class HeapSnapshot implements M.HeapSnapshot {
mergedDominatorTree =
new HeapSnapshotMergedDominatorNode(isolate, graph.mergedRoot);
classReferences = await buildMergedVertices(isolate, graph, signal);
+ ownershipClasses = buildOwnershipClasses(isolate, graph);
progress.close();
}());
return progress.stream;
@@ -100,6 +102,18 @@ class HeapSnapshot implements M.HeapSnapshot {
return cidToMergedVertex.values.toList();
}
+ buildOwnershipClasses(S.Isolate isolate, ObjectGraph graph) {
+ var numCids = graph.numCids;
+ var classes = new List();
+ for (var cid = 0; cid < numCids; cid++) {
+ var size = graph.getOwnedByCid(cid);
+ if (size != 0) {
+ classes.add(new HeapSnapshotOwnershipClass(cid, isolate, size));
+ }
+ }
+ return classes;
+ }
+
List<Future<S.ServiceObject>> getMostRetained(S.Isolate isolate,
{int classId, int limit}) {
var result = [];
@@ -267,3 +281,12 @@ class HeapSnapshotClassOutbound implements M.HeapSnapshotClassOutbound {
HeapSnapshotClassOutbound(this.vertex, this.edge);
}
+
+class HeapSnapshotOwnershipClass implements M.HeapSnapshotOwnershipClass {
+ final int cid;
+ final S.Isolate isolate;
+ S.Class get clazz => isolate.getClassByCid(cid);
+ final int size;
+
+ HeapSnapshotOwnershipClass(this.cid, this.isolate, this.size);
+}
« no previous file with comments | « runtime/observatory/lib/src/elements/heap_snapshot.dart ('k') | runtime/observatory/lib/src/models/objects/heap_snapshot.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698