Chromium Code Reviews| Index: runtime/observatory/lib/src/service/object.dart |
| =================================================================== |
| --- runtime/observatory/lib/src/service/object.dart (revision 42649) |
| +++ runtime/observatory/lib/src/service/object.dart (working copy) |
| @@ -693,6 +693,32 @@ |
| } |
| } |
| +class HeapSnapshot extends Observable { |
|
Cutch
2015/01/07 00:25:26
Why does this class extend from Observable?
koda
2015/01/09 18:46:56
Done.
|
| + final ObjectGraph graph; |
| + final DateTime timeStamp; |
| + final Isolate isolate; |
| + |
| + HeapSnapshot(this.isolate, ByteData data) : |
| + graph = new ObjectGraph(new ReadStream(data)), |
| + timeStamp = new DateTime.now() { |
| + } |
| + |
| + List<Future<ServiceObject>> getMostRetained({int classId, int limit}) { |
| + var result = []; |
| + for (var v in graph.getMostRetained(classId: classId, limit: limit)) { |
| + var address = v.addressForWordSize(isolate.vm.architectureBits ~/ 8); |
| + result.add(isolate.get( |
| + 'address/${address.toRadixString(16)}?ref=true').then((obj) { |
| + obj.retainedSize = v.retainedSize; |
| + return new Future(() => obj); |
| + })); |
| + } |
| + return result; |
| + } |
| + |
| + |
| +} |
| + |
| /// State for a running isolate. |
| class Isolate extends ServiceObjectOwner with Coverage { |
| @reflectable VM get vm => owner; |
| @@ -854,6 +880,21 @@ |
| @observable String fileAndLine; |
| @observable DartError error; |
| + @observable HeapSnapshot latestSnapshot; |
| + Completer<HeapSnapshot> snapshotFetch; |
|
Cutch
2015/01/07 00:25:26
Any reason why snapshotFetch is public?
koda
2015/01/09 18:46:56
Done.
|
| + |
| + void loadHeapSnapshot(ServiceEvent event) { |
|
Cutch
2015/01/07 00:25:26
Any reason why this is public?
...
I see now tha
koda
2015/01/09 18:46:55
Yes. I think there should be per-isolate event str
|
| + latestSnapshot = new HeapSnapshot(this, event.data); |
| + snapshotFetch.complete(latestSnapshot); |
| + } |
| + |
| + Future<HeapSnapshot> fetchHeapSnapshot() { |
| + if (snapshotFetch == null || snapshotFetch.isCompleted) { |
| + get('graph'); |
| + snapshotFetch = new Completer<HeapSnapshot>(); |
| + } |
| + return snapshotFetch.future; |
| + } |
| void updateHeapsFromMap(ObservableMap map) { |
| newSpace.update(map['new']); |
| @@ -1541,6 +1582,7 @@ |
| class Instance extends ServiceObject { |
| @observable Class clazz; |
| @observable int size; |
| + @observable int retainedSize; |
| @observable String valueAsString; // If primitive. |
| @observable bool valueAsStringIsTruncated; |
| @observable ServiceFunction closureFunc; // If a closure. |