| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 5 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 6 // for details. All rights reserved. Use of this source code is governed by a | 6 // for details. All rights reserved. Use of this source code is governed by a |
| 7 // BSD-style license that can be found in the LICENSE file. | 7 // BSD-style license that can be found in the LICENSE file. |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:html'; | 10 import 'dart:html'; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 break; | 133 break; |
| 134 case M.HeapSnapshotLoadingStatus.loaded: | 134 case M.HeapSnapshotLoadingStatus.loaded: |
| 135 content.addAll(_createReport()); | 135 content.addAll(_createReport()); |
| 136 break; | 136 break; |
| 137 } | 137 } |
| 138 children = content; | 138 children = content; |
| 139 } | 139 } |
| 140 | 140 |
| 141 Future _refresh() async { | 141 Future _refresh() async { |
| 142 _progress = null; | 142 _progress = null; |
| 143 _progressStream = _snapshots.get(isolate, | 143 _progressStream = _snapshots.get(isolate, roots: _roots, gc: true); |
| 144 roots: _roots, | |
| 145 gc: true); | |
| 146 _r.dirty(); | 144 _r.dirty(); |
| 147 _progressStream.listen((e) { | 145 _progressStream.listen((e) { |
| 148 _progress = e.progress; | 146 _progress = e.progress; |
| 149 _r.dirty(); | 147 _r.dirty(); |
| 150 }); | 148 }); |
| 151 _progress = (await _progressStream.first).progress; | 149 _progress = (await _progressStream.first).progress; |
| 152 _r.dirty(); | 150 _r.dirty(); |
| 153 if (M.isHeapSnapshotProgressRunning(_progress.status)) { | 151 if (M.isHeapSnapshotProgressRunning(_progress.status)) { |
| 154 _progress = (await _progressStream.last).progress; | 152 _progress = (await _progressStream.last).progress; |
| 155 _snapshot = _progress.snapshot; | 153 _snapshot = _progress.snapshot; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 'that would be freed if the object became garbage.'; | 272 'that would be freed if the object became garbage.'; |
| 275 report.addAll([ | 273 report.addAll([ |
| 276 new DivElement() | 274 new DivElement() |
| 277 ..classes = ['content-centered-big', 'explanation'] | 275 ..classes = ['content-centered-big', 'explanation'] |
| 278 ..text = text | 276 ..text = text |
| 279 ..title = text, | 277 ..title = text, |
| 280 _tree | 278 _tree |
| 281 ]); | 279 ]); |
| 282 break; | 280 break; |
| 283 case HeapSnapshotTreeMode.mergedDominatorTree: | 281 case HeapSnapshotTreeMode.mergedDominatorTree: |
| 284 _tree = new VirtualTreeElement( | 282 _tree = new VirtualTreeElement(_createMergedDominator, |
| 285 _createMergedDominator, _updateMergedDominator, | 283 _updateMergedDominator, _getChildrenMergedDominator, |
| 286 _getChildrenMergedDominator, | |
| 287 items: _getChildrenMergedDominator(_snapshot.mergedDominatorTree), | 284 items: _getChildrenMergedDominator(_snapshot.mergedDominatorTree), |
| 288 queue: _r.queue); | 285 queue: _r.queue); |
| 289 _tree.expand(_snapshot.mergedDominatorTree); | 286 _tree.expand(_snapshot.mergedDominatorTree); |
| 290 final text = 'A heap dominator tree, where siblings with the same class' | 287 final text = 'A heap dominator tree, where siblings with the same class' |
| 291 ' have been merged into a single node.'; | 288 ' have been merged into a single node.'; |
| 292 report.addAll([ | 289 report.addAll([ |
| 293 new DivElement() | 290 new DivElement() |
| 294 ..classes = ['content-centered-big', 'explanation'] | 291 ..classes = ['content-centered-big', 'explanation'] |
| 295 ..text = text | 292 ..text = text |
| 296 ..title = text, | 293 ..title = text, |
| 297 _tree | 294 _tree |
| 298 ]); | 295 ]); |
| 299 break; | 296 break; |
| 300 case HeapSnapshotTreeMode.groupByClass: | 297 case HeapSnapshotTreeMode.groupByClass: |
| 301 final items = _snapshot.classReferences.toList(); | 298 final items = _snapshot.classReferences.toList(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 static const int kMaxChildren = 100; | 366 static const int kMaxChildren = 100; |
| 370 static const int kMinRetainedSize = 4096; | 367 static const int kMinRetainedSize = 4096; |
| 371 | 368 |
| 372 static _getChildrenDominator(M.HeapSnapshotDominatorNode node) { | 369 static _getChildrenDominator(M.HeapSnapshotDominatorNode node) { |
| 373 final list = node.children.toList(); | 370 final list = node.children.toList(); |
| 374 list.sort((a, b) => b.retainedSize - a.retainedSize); | 371 list.sort((a, b) => b.retainedSize - a.retainedSize); |
| 375 return list | 372 return list |
| 376 .where((child) => child.retainedSize >= kMinRetainedSize) | 373 .where((child) => child.retainedSize >= kMinRetainedSize) |
| 377 .take(kMaxChildren); | 374 .take(kMaxChildren); |
| 378 } | 375 } |
| 376 |
| 379 static _getChildrenMergedDominator(M.HeapSnapshotMergedDominatorNode node) { | 377 static _getChildrenMergedDominator(M.HeapSnapshotMergedDominatorNode node) { |
| 380 final list = node.children.toList(); | 378 final list = node.children.toList(); |
| 381 list.sort((a, b) => b.retainedSize - a.retainedSize); | 379 list.sort((a, b) => b.retainedSize - a.retainedSize); |
| 382 return list | 380 return list |
| 383 .where((child) => child.retainedSize >= kMinRetainedSize) | 381 .where((child) => child.retainedSize >= kMinRetainedSize) |
| 384 .take(kMaxChildren); | 382 .take(kMaxChildren); |
| 385 } | 383 } |
| 386 | 384 |
| 387 static _getChildrenGroup(item) { | 385 static _getChildrenGroup(item) { |
| 388 if (item is M.HeapSnapshotClassReferences) { | 386 if (item is M.HeapSnapshotClassReferences) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 407 element.children[3].text = | 405 element.children[3].text = |
| 408 Utils.formatPercentNormalized(node.retainedSize * 1.0 / _snapshot.size); | 406 Utils.formatPercentNormalized(node.retainedSize * 1.0 / _snapshot.size); |
| 409 final wrapper = new SpanElement() | 407 final wrapper = new SpanElement() |
| 410 ..classes = ['name'] | 408 ..classes = ['name'] |
| 411 ..text = 'Loading...'; | 409 ..text = 'Loading...'; |
| 412 element.children[4] = wrapper; | 410 element.children[4] = wrapper; |
| 413 if (node.isStack) { | 411 if (node.isStack) { |
| 414 wrapper | 412 wrapper |
| 415 ..text = '' | 413 ..text = '' |
| 416 ..children = [ | 414 ..children = [ |
| 417 new AnchorElement(href: Uris.debugger(isolate)) | 415 new AnchorElement(href: Uris.debugger(isolate))..text = 'stack frames' |
| 418 ..text = 'stack frames' | |
| 419 ]; | 416 ]; |
| 420 } else { | 417 } else { |
| 421 node.object.then((object) { | 418 node.object.then((object) { |
| 422 wrapper | 419 wrapper |
| 423 ..text = '' | 420 ..text = '' |
| 424 ..children = [anyRef(_isolate, object, _instances, queue: _r.queue)]; | 421 ..children = [anyRef(_isolate, object, _instances, queue: _r.queue)]; |
| 425 }); | 422 }); |
| 426 } | 423 } |
| 427 } | 424 } |
| 428 | 425 |
| 429 void _updateMergedDominator( | 426 void _updateMergedDominator( |
| 430 HtmlElement element, M.HeapSnapshotMergedDominatorNode node, int depth) { | 427 HtmlElement element, M.HeapSnapshotMergedDominatorNode node, int depth) { |
| 431 element.children[0].text = Utils.formatSize(node.retainedSize); | 428 element.children[0].text = Utils.formatSize(node.retainedSize); |
| 432 _updateLines(element.children[1].children, depth); | 429 _updateLines(element.children[1].children, depth); |
| 433 if (_getChildrenMergedDominator(node).isNotEmpty) { | 430 if (_getChildrenMergedDominator(node).isNotEmpty) { |
| 434 element.children[2].text = _tree.isExpanded(node) ? '▼' : '►'; | 431 element.children[2].text = _tree.isExpanded(node) ? '▼' : '►'; |
| 435 } else { | 432 } else { |
| 436 element.children[2].text = ''; | 433 element.children[2].text = ''; |
| 437 } | 434 } |
| 438 element.children[3].text = | 435 element.children[3].text = |
| 439 Utils.formatPercentNormalized(node.retainedSize * 1.0 / _snapshot.size); | 436 Utils.formatPercentNormalized(node.retainedSize * 1.0 / _snapshot.size); |
| 440 final wrapper = new SpanElement() | 437 final wrapper = new SpanElement() |
| 441 ..classes = ['name'] | 438 ..classes = ['name'] |
| 442 ..text = 'Loading...'; | 439 ..text = 'Loading...'; |
| 443 element.children[4] = wrapper; | 440 element.children[4] = wrapper; |
| 444 if (node.isStack) { | 441 if (node.isStack) { |
| 445 wrapper | 442 wrapper |
| 446 ..text = '' | 443 ..text = '' |
| 447 ..children = [ | 444 ..children = [ |
| 448 new AnchorElement(href: Uris.debugger(isolate)) | 445 new AnchorElement(href: Uris.debugger(isolate))..text = 'stack frames' |
| 449 ..text = 'stack frames' | |
| 450 ]; | 446 ]; |
| 451 } else { | 447 } else { |
| 452 node.klass.then((klass) { | 448 node.klass.then((klass) { |
| 453 wrapper | 449 wrapper |
| 454 ..text = '' | 450 ..text = '' |
| 455 ..children = [ | 451 ..children = [ |
| 456 new SpanElement()..text = '${node.instanceCount} instances of ', | 452 new SpanElement()..text = '${node.instanceCount} instances of ', |
| 457 anyRef(_isolate, klass, _instances, queue: _r.queue) | 453 anyRef(_isolate, klass, _instances, queue: _r.queue) |
| 458 ]; | 454 ]; |
| 459 }); | 455 }); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 value: modeToString(mode), | 566 value: modeToString(mode), |
| 571 selected: _mode == mode)..text = modeToString(mode); | 567 selected: _mode == mode)..text = modeToString(mode); |
| 572 }).toList(growable: false) | 568 }).toList(growable: false) |
| 573 ..onChange.listen((_) { | 569 ..onChange.listen((_) { |
| 574 _mode = HeapSnapshotTreeMode.values[s.selectedIndex]; | 570 _mode = HeapSnapshotTreeMode.values[s.selectedIndex]; |
| 575 _r.dirty(); | 571 _r.dirty(); |
| 576 }) | 572 }) |
| 577 ]; | 573 ]; |
| 578 } | 574 } |
| 579 } | 575 } |
| OLD | NEW |