| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of service; | 5 part of service; |
| 6 | 6 |
| 7 /// A [ServiceObject] is an object known to the VM service and is tied | 7 /// A [ServiceObject] is an object known to the VM service and is tied |
| 8 /// to an owning [Isolate]. | 8 /// to an owning [Isolate]. |
| 9 abstract class ServiceObject extends Observable { | 9 abstract class ServiceObject extends Observable { |
| 10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { | 10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 void update(Map heapMap) { | 686 void update(Map heapMap) { |
| 687 used = heapMap['used']; | 687 used = heapMap['used']; |
| 688 capacity = heapMap['capacity']; | 688 capacity = heapMap['capacity']; |
| 689 external = heapMap['external']; | 689 external = heapMap['external']; |
| 690 collections = heapMap['collections']; | 690 collections = heapMap['collections']; |
| 691 totalCollectionTimeInSeconds = heapMap['time']; | 691 totalCollectionTimeInSeconds = heapMap['time']; |
| 692 averageCollectionPeriodInMillis = heapMap['avgCollectionPeriodMillis']; | 692 averageCollectionPeriodInMillis = heapMap['avgCollectionPeriodMillis']; |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 | 695 |
| 696 class HeapSnapshot { |
| 697 final ObjectGraph graph; |
| 698 final DateTime timeStamp; |
| 699 final Isolate isolate; |
| 700 |
| 701 HeapSnapshot(this.isolate, ByteData data) : |
| 702 graph = new ObjectGraph(new ReadStream(data)), |
| 703 timeStamp = new DateTime.now() { |
| 704 } |
| 705 |
| 706 List<Future<ServiceObject>> getMostRetained({int classId, int limit}) { |
| 707 var result = []; |
| 708 for (var v in graph.getMostRetained(classId: classId, limit: limit)) { |
| 709 var address = v.addressForWordSize(isolate.vm.architectureBits ~/ 8); |
| 710 result.add(isolate.get( |
| 711 'address/${address.toRadixString(16)}?ref=true').then((obj) { |
| 712 obj.retainedSize = v.retainedSize; |
| 713 return new Future(() => obj); |
| 714 })); |
| 715 } |
| 716 return result; |
| 717 } |
| 718 |
| 719 |
| 720 } |
| 721 |
| 696 /// State for a running isolate. | 722 /// State for a running isolate. |
| 697 class Isolate extends ServiceObjectOwner with Coverage { | 723 class Isolate extends ServiceObjectOwner with Coverage { |
| 698 @reflectable VM get vm => owner; | 724 @reflectable VM get vm => owner; |
| 699 @reflectable Isolate get isolate => this; | 725 @reflectable Isolate get isolate => this; |
| 700 @observable ObservableMap counters = new ObservableMap(); | 726 @observable ObservableMap counters = new ObservableMap(); |
| 701 | 727 |
| 702 String get link => '/${_id}'; | 728 String get link => '/${_id}'; |
| 703 | 729 |
| 704 @observable ServiceEvent pauseEvent = null; | 730 @observable ServiceEvent pauseEvent = null; |
| 705 bool get _isPaused => pauseEvent != null; | 731 bool get _isPaused => pauseEvent != null; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 | 873 |
| 848 @observable final Map<String, double> timers = | 874 @observable final Map<String, double> timers = |
| 849 toObservable(new Map<String, double>()); | 875 toObservable(new Map<String, double>()); |
| 850 | 876 |
| 851 final HeapSpace newSpace = new HeapSpace(); | 877 final HeapSpace newSpace = new HeapSpace(); |
| 852 final HeapSpace oldSpace = new HeapSpace(); | 878 final HeapSpace oldSpace = new HeapSpace(); |
| 853 | 879 |
| 854 @observable String fileAndLine; | 880 @observable String fileAndLine; |
| 855 | 881 |
| 856 @observable DartError error; | 882 @observable DartError error; |
| 883 @observable HeapSnapshot latestSnapshot; |
| 884 Completer<HeapSnapshot> _snapshotFetch; |
| 885 |
| 886 void loadHeapSnapshot(ServiceEvent event) { |
| 887 latestSnapshot = new HeapSnapshot(this, event.data); |
| 888 _snapshotFetch.complete(latestSnapshot); |
| 889 } |
| 890 |
| 891 Future<HeapSnapshot> fetchHeapSnapshot() { |
| 892 if (_snapshotFetch == null || _snapshotFetch.isCompleted) { |
| 893 get('graph'); |
| 894 _snapshotFetch = new Completer<HeapSnapshot>(); |
| 895 } |
| 896 return _snapshotFetch.future; |
| 897 } |
| 857 | 898 |
| 858 void updateHeapsFromMap(ObservableMap map) { | 899 void updateHeapsFromMap(ObservableMap map) { |
| 859 newSpace.update(map['new']); | 900 newSpace.update(map['new']); |
| 860 oldSpace.update(map['old']); | 901 oldSpace.update(map['old']); |
| 861 } | 902 } |
| 862 | 903 |
| 863 void _update(ObservableMap map, bool mapIsRef) { | 904 void _update(ObservableMap map, bool mapIsRef) { |
| 864 mainPort = map['mainPort']; | 905 mainPort = map['mainPort']; |
| 865 name = map['name']; | 906 name = map['name']; |
| 866 vmName = map['name']; | 907 vmName = map['name']; |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 Future<ServiceObject> get(String command) { | 1575 Future<ServiceObject> get(String command) { |
| 1535 return isolate.get(id + "/$command"); | 1576 return isolate.get(id + "/$command"); |
| 1536 } | 1577 } |
| 1537 | 1578 |
| 1538 String toString() => 'Class($vmName)'; | 1579 String toString() => 'Class($vmName)'; |
| 1539 } | 1580 } |
| 1540 | 1581 |
| 1541 class Instance extends ServiceObject { | 1582 class Instance extends ServiceObject { |
| 1542 @observable Class clazz; | 1583 @observable Class clazz; |
| 1543 @observable int size; | 1584 @observable int size; |
| 1585 @observable int retainedSize; |
| 1544 @observable String valueAsString; // If primitive. | 1586 @observable String valueAsString; // If primitive. |
| 1545 @observable bool valueAsStringIsTruncated; | 1587 @observable bool valueAsStringIsTruncated; |
| 1546 @observable ServiceFunction closureFunc; // If a closure. | 1588 @observable ServiceFunction closureFunc; // If a closure. |
| 1547 @observable Context closureCtxt; // If a closure. | 1589 @observable Context closureCtxt; // If a closure. |
| 1548 @observable String name; // If a Type. | 1590 @observable String name; // If a Type. |
| 1549 @observable int length; // If a List. | 1591 @observable int length; // If a List. |
| 1550 | 1592 |
| 1551 @observable var typeClass; | 1593 @observable var typeClass; |
| 1552 @observable var fields; | 1594 @observable var fields; |
| 1553 @observable var nativeFields; | 1595 @observable var nativeFields; |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2735 var v = list[i]; | 2777 var v = list[i]; |
| 2736 if ((v is ObservableMap) && _isServiceMap(v)) { | 2778 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 2737 list[i] = owner.getFromMap(v); | 2779 list[i] = owner.getFromMap(v); |
| 2738 } else if (v is ObservableList) { | 2780 } else if (v is ObservableList) { |
| 2739 _upgradeObservableList(v, owner); | 2781 _upgradeObservableList(v, owner); |
| 2740 } else if (v is ObservableMap) { | 2782 } else if (v is ObservableMap) { |
| 2741 _upgradeObservableMap(v, owner); | 2783 _upgradeObservableMap(v, owner); |
| 2742 } | 2784 } |
| 2743 } | 2785 } |
| 2744 } | 2786 } |
| OLD | NEW |