Web Inspector: Retained size for classes is too conservative in heap profiler

https://bugs.webkit.org/show_bug.cgi?id=77726

Patch by Alexei Filippov <alexeif@chromium.org> on 2012-02-03
Reviewed by Yury Semikhatsky.

Makes retained size of all objects of particular class show correct value
in Summary view of heap profiler.

* inspector/front-end/DetailedHeapshotGridNodes.js:
(WebInspector.HeapSnapshotConstructorNode.prototype.get data):
* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshot.prototype._buildAggregates):
(WebInspector.HeapSnapshot.prototype._buildAggregates.forDominatedNodes):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cd99b22b
2012-02-03 Alexei Filippov <alexeif@chromium.org>
Web Inspector: Retained size for classes is too conservative in heap profiler
https://bugs.webkit.org/show_bug.cgi?id=77726
Reviewed by Yury Semikhatsky.
Makes retained size of all objects of particular class show correct value
in Summary view of heap profiler.
* inspector/front-end/DetailedHeapshotGridNodes.js:
(WebInspector.HeapSnapshotConstructorNode.prototype.get data):
* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshot.prototype._buildAggregates):
(WebInspector.HeapSnapshot.prototype._buildAggregates.forDominatedNodes):
2012-02-02 Alexander Pavlov <apavlov@chromium.org>
Web Inspector: Introduce "Copy XPath" popup menu item for DOM elements
......@@ -607,7 +607,7 @@ WebInspector.HeapSnapshotConstructorNode.prototype = {
var view = this.dataGrid.snapshotView;
data["count"] = Number.withThousandsSeparator(this._count);
data["shallowSize"] = Number.withThousandsSeparator(this._shallowSize);
data["retainedSize"] = Number.withThousandsSeparator(this._retainedSize) + "+";
data["retainedSize"] = Number.withThousandsSeparator(this._retainedSize);
if (view._showPercentage) {
data["shallowSize-percent"] = this._toPercentString(this._shallowSizePercent);
data["retainedSize-percent"] = this._toPercentString(this._retainedSizePercent);
......
......@@ -915,28 +915,56 @@ WebInspector.HeapSnapshot.prototype = {
_buildAggregates: function(filter)
{
var aggregates = {};
for (var iter = this._allNodes; iter.hasNext(); iter.next()) {
var node = iter.node;
function shouldSkip(node)
{
if (filter && !filter(node))
continue;
return true;
if (node.type !== "native" && node.selfSize === 0)
continue;
return true;
var className = node.className;
if (className === "Document DOM tree")
continue;
return true;
if (className === "Detached DOM tree")
return true;
return false;
}
var aggregates = {};
for (var iter = this._allNodes; iter.hasNext(); iter.next()) {
var node = iter.node;
if (shouldSkip(node))
continue;
var className = node.className;
var nameMatters = node.type === "object" || node.type === "native";
if (!aggregates.hasOwnProperty(className))
aggregates[className] = { count: 0, self: 0, maxRet: 0, type: node.type, name: nameMatters ? node.name : null, idxs: [] };
var clss = aggregates[className];
++clss.count;
clss.self += node.selfSize;
if (node.retainedSize > clss.maxRet)
clss.maxRet = node.retainedSize;
clss.idxs.push(node.nodeIndex);
}
// Recursively visit dominators tree and sum up retained sizes
// of topmost objects in each class.
// This gives us retained sizes for classes.
var seenClasses = {};
var snapshot = this;
function forDominatedNodes(nodeIndex)
{
var node = new WebInspector.HeapSnapshotNode(snapshot, nodeIndex);
var className = node.className;
var seen = !!seenClasses[className];
if (!seen && className in aggregates && !shouldSkip(node)) {
aggregates[className].maxRet += node.retainedSize;
seenClasses[className] = true;
}
var dominatedNodes = snapshot._dominatedNodesOfNode(node);
for (var i = 0; i < dominatedNodes.length; i++)
forDominatedNodes(dominatedNodes.item(i));
seenClasses[className] = seen;
}
forDominatedNodes(this._rootNodeIndex);
// Shave off provisionally allocated space.
for (var className in aggregates)
aggregates[className].idxs = aggregates[className].idxs.slice(0);
......
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