Commit 5d60f6db authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

DevTools: Do not update memory usage when Memory landing page is not visible.

Change-Id: I0a07c50c28c4719a18f01305511d63574094f604
Reviewed-on: https://chromium-review.googlesource.com/1115818
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572308}
parent a61a583d
...@@ -21,12 +21,27 @@ Profiler.IsolateSelector = class extends UI.VBox { ...@@ -21,12 +21,27 @@ Profiler.IsolateSelector = class extends UI.VBox {
this._isolateByModel = new Map(); this._isolateByModel = new Map();
/** @type {!Map<string, !Profiler.IsolateSelector.ListItem>} */ /** @type {!Map<string, !Profiler.IsolateSelector.ListItem>} */
this._itemByIsolate = new Map(); this._itemByIsolate = new Map();
this._updateTimer = null;
SDK.targetManager.observeModels(SDK.RuntimeModel, this); SDK.targetManager.observeModels(SDK.RuntimeModel, this);
SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, this._targetChanged, this); SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, this._targetChanged, this);
SDK.targetManager.addEventListener(SDK.TargetManager.Events.InspectedURLChanged, this._targetChanged, this); SDK.targetManager.addEventListener(SDK.TargetManager.Events.InspectedURLChanged, this._targetChanged, this);
} }
/**
* @override
*/
wasShown() {
this._updateStats();
}
/**
* @override
*/
willHide() {
clearTimeout(this._updateTimer);
}
/** /**
* @override * @override
* @param {!SDK.RuntimeModel} model * @param {!SDK.RuntimeModel} model
...@@ -137,6 +152,13 @@ Profiler.IsolateSelector = class extends UI.VBox { ...@@ -137,6 +152,13 @@ Profiler.IsolateSelector = class extends UI.VBox {
_update() { _update() {
this._list.invalidateRange(0, this._items.length); this._list.invalidateRange(0, this._items.length);
} }
_updateStats() {
for (const item of this._itemByIsolate.values())
item.updateStats();
const heapStatsUpdateIntervalMs = 2000;
this._updateTimer = setTimeout(() => this._updateStats(), heapStatsUpdateIntervalMs);
}
}; };
Profiler.IsolateSelector.ListItem = class { Profiler.IsolateSelector.ListItem = class {
...@@ -149,9 +171,9 @@ Profiler.IsolateSelector.ListItem = class { ...@@ -149,9 +171,9 @@ Profiler.IsolateSelector.ListItem = class {
this.element = createElementWithClass('div', 'profile-isolate-item hbox'); this.element = createElementWithClass('div', 'profile-isolate-item hbox');
this._heapDiv = this.element.createChild('div', 'profile-isolate-item-heap'); this._heapDiv = this.element.createChild('div', 'profile-isolate-item-heap');
this._nameDiv = this.element.createChild('div', 'profile-isolate-item-name'); this._nameDiv = this.element.createChild('div', 'profile-isolate-item-name');
this._updateTimer = null; this._updatesDisabled = false;
this.updateTitle(); this.updateTitle();
this._updateStats(); this.updateStats();
} }
/** /**
...@@ -168,9 +190,6 @@ Profiler.IsolateSelector.ListItem = class { ...@@ -168,9 +190,6 @@ Profiler.IsolateSelector.ListItem = class {
removeModel(model) { removeModel(model) {
this._models.delete(model); this._models.delete(model);
this.updateTitle(); this.updateTitle();
if (this._models.size)
return;
clearTimeout(this._updateTimer);
} }
/** /**
...@@ -180,10 +199,14 @@ Profiler.IsolateSelector.ListItem = class { ...@@ -180,10 +199,14 @@ Profiler.IsolateSelector.ListItem = class {
return Array.from(this._models); return Array.from(this._models);
} }
async _updateStats() { async updateStats() {
if (this._updatesDisabled)
return;
const heapStats = await this._models.values().next().value.heapUsage(); const heapStats = await this._models.values().next().value.heapUsage();
if (!heapStats) if (!heapStats) {
this._updatesDisabled = true;
return; return;
}
const usedTitle = ls`Heap size in use by live JS objects.`; const usedTitle = ls`Heap size in use by live JS objects.`;
const totalTitle = ls`Total JS heap size including live objects, garbage, and reserved space.`; const totalTitle = ls`Total JS heap size including live objects, garbage, and reserved space.`;
this._heapDiv.removeChildren(); this._heapDiv.removeChildren();
...@@ -206,10 +229,8 @@ Profiler.IsolateSelector.ListItem = class { ...@@ -206,10 +229,8 @@ Profiler.IsolateSelector.ListItem = class {
} }
this._nameDiv.removeChildren(); this._nameDiv.removeChildren();
for (const [name, count] of modelCountByName) { for (const [name, count] of modelCountByName) {
const lineDiv = this._nameDiv.createChild('div');
const title = count > 1 ? `${name} (${count})` : name; const title = count > 1 ? `${name} (${count})` : name;
lineDiv.textContent = title; this._nameDiv.appendChild(UI.html`<div title="${title}">${title}</div>`);
lineDiv.setAttribute('title', title);
} }
} }
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment