Index: runtime/observatory/lib/src/elements/heap_profile.dart |
=================================================================== |
--- runtime/observatory/lib/src/elements/heap_profile.dart (revision 44977) |
+++ runtime/observatory/lib/src/elements/heap_profile.dart (working copy) |
@@ -6,6 +6,7 @@ |
import 'dart:html'; |
import 'observatory_element.dart'; |
+import 'package:logging/logging.dart'; |
import 'package:observatory/app.dart'; |
import 'package:observatory/service.dart'; |
import 'package:observatory/elements.dart'; |
@@ -102,13 +103,34 @@ |
_subscription.cancel((){}); |
super.detached(); |
} |
- |
+ |
+ // Keep at most one outstanding auto-refresh RPC. |
+ bool refreshAutoPending = false; |
+ bool refreshAutoQueued = false; |
+ |
void _onEvent(ServiceEvent event) { |
if (autoRefresh && event.eventType == 'GC') { |
- refresh((){}); |
+ if (!refreshAutoPending) { |
+ refreshAuto(); |
+ } else { |
+ // Remember to refresh once more, to ensure latest profile. |
+ refreshAutoQueued = true; |
+ } |
} |
} |
+ void refreshAuto() { |
+ refreshAutoPending = true; |
+ refreshAutoQueued = false; |
+ refresh(() { |
+ refreshAutoPending = false; |
+ // Keep refreshing if at least one GC event was received while waiting. |
+ if (refreshAutoQueued) { |
+ refreshAuto(); |
+ } |
+ }); |
+ } |
+ |
void _updatePieCharts() { |
assert(profile != null); |
_newPieDataTable.clearRows(); |