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

Unified Diff: runtime/observatory/lib/object_graph.dart

Issue 818733002: Rank most retaining instances for each class. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | runtime/observatory/lib/service.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/object_graph.dart
===================================================================
--- runtime/observatory/lib/object_graph.dart (revision 42649)
+++ runtime/observatory/lib/object_graph.dart (working copy)
@@ -38,6 +38,9 @@
class ObjectVertex {
// Never null. The isolate root has id 0.
final int _id;
+ bool get isRoot => _id == 0;
+ // TODO(koda): Include units in object graph metadata.
+ int addressForWordSize(int bytesPerWord) => _id * 2 * bytesPerWord;
// null for VM-heap objects.
int _shallowSize;
int get shallowSize => _shallowSize;
@@ -75,12 +78,27 @@
_addFrom(reader);
}
_computeRetainedSizes();
+ _mostRetained = new List<ObjectVertex>.from(
+ vertices.where((u) => !u.isRoot));
+ _mostRetained.sort((u, v) => v.retainedSize - u.retainedSize);
}
Iterable<ObjectVertex> get vertices => _idToVertex.values;
+ List<ObjectVertex> _mostRetained;
ObjectVertex get root => _asVertex(0);
+ Iterable<ObjectVertex> getMostRetained({int classId, int limit}) {
+ var result = _mostRetained;
+ if (classId != null) {
+ result = result.where((u) => u.classId == classId);
+ }
+ if (limit != null) {
+ result = result.take(limit);
+ }
+ return result;
+ }
+
void _computeRetainedSizes() {
// The retained size for an object is the sum of the shallow sizes of
// all its descendants in the dominator tree (including itself).
« no previous file with comments | « no previous file | runtime/observatory/lib/service.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698