Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause should still record memory stats just not update charts. #2382

Merged
merged 2 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/devtools_app/lib/src/memory/memory_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ class MemoryChartState extends State<MemoryChart> with AutoDisposeMixin {

/// Display any newly received heap sample(s) in the chart.
void _updateAllCharts() {
// If paused don't update the chart (data is still collected).
if (controller.paused.value) return;

setState(() {
// Update Dart VM chart datasets.
dartChartController.data = LineData.fromList(chartDatasets);
Expand Down
15 changes: 8 additions & 7 deletions packages/devtools_app/lib/src/memory/memory_events_pane.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class MemoryEventsPaneState extends State<MemoryEventsPane>

/// Loads all heap samples (live data or offline).
void _processAndUpdate() {
// If paused don't update the chart (data is still collected).
if (_memoryController.paused.value) return;

setState(() {
// Display new events in the pane.
_updateEventPane();
Expand All @@ -252,14 +255,12 @@ class MemoryEventsPaneState extends State<MemoryEventsPane>

/// Display any newly received events in the chart.
void _updateEventPane() {
setState(() {
_controller.data = ScatterData.fromList(datasets);
_controller.data = ScatterData.fromList(datasets);

// Received new samples ready to plot, signal data has changed.
for (final dataset in datasets) {
dataset.notifyDataSetChanged();
}
});
// Received new samples ready to plot, signal data has changed.
for (final dataset in datasets) {
dataset.notifyDataSetChanged();
}
}

@override
Expand Down
22 changes: 9 additions & 13 deletions packages/devtools_app/lib/src/memory/memory_protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,20 @@ class MemoryTracker {
// A service of null implies we're disconnected - signal paused.
memoryController.pauseLiveFeed();
}
paused ??= memoryController.paused.value;

if (paused) {
_pollingTimer?.cancel();
_gcStreamListener?.cancel();
_gcStreamListener = null;
_pollingTimer = null;
} else {
_pollingTimer ??= Timer(MemoryTimeline.updateDelay, _pollMemory);
_gcStreamListener ??= service?.onGCEvent?.listen(_handleGCEvent);
}
_pollingTimer ??= Timer(MemoryTimeline.updateDelay, _pollMemory);
_gcStreamListener ??= service?.onGCEvent?.listen(_handleGCEvent);
}

void stop() {
_updateLiveDataPolling(false);
memoryController.paused.removeListener(_updateLiveDataPolling);

_pollingTimer?.cancel();
_gcStreamListener?.cancel();
_gcStreamListener = null;
_pollingTimer = null;

serviceManager = null;
}

Expand Down Expand Up @@ -128,9 +126,7 @@ class MemoryTracker {
// Polls for current RSS size.
_update(await service.getVM(), isolateMemory);

if (!memoryController.paused.value) {
_pollingTimer ??= Timer(MemoryTimeline.updateDelay, _pollMemory);
}
_pollingTimer ??= Timer(MemoryTimeline.updateDelay, _pollMemory);
}

void _update(VM vm, Map<IsolateRef, MemoryUsage> isolateMemory) {
Expand Down