Don't show sizes with sample paths.
Because they clutter the sample path without adding much value.
Test: Look at the page for an object in ahat.
Change-Id: I722c3c99c98b39f5d620acf84c8ffa3cddb90df0
diff --git a/tools/ahat/README.txt b/tools/ahat/README.txt
index 133426f..3049871 100644
--- a/tools/ahat/README.txt
+++ b/tools/ahat/README.txt
@@ -75,6 +75,9 @@
* Instance.isRoot and Instance.getRootTypes.
Release History:
+ 1.2 Pending
+ Simplify presentation of sample path from gc root.
+
1.1 Feb 21, 2017
Show java.lang.ref.Reference referents as "unreachable" instead of null.
diff --git a/tools/ahat/src/ObjectHandler.java b/tools/ahat/src/ObjectHandler.java
index 2e0ae6e..b1d7904 100644
--- a/tools/ahat/src/ObjectHandler.java
+++ b/tools/ahat/src/ObjectHandler.java
@@ -19,7 +19,6 @@
import com.android.ahat.heapdump.AhatArrayInstance;
import com.android.ahat.heapdump.AhatClassInstance;
import com.android.ahat.heapdump.AhatClassObj;
-import com.android.ahat.heapdump.AhatHeap;
import com.android.ahat.heapdump.AhatInstance;
import com.android.ahat.heapdump.AhatSnapshot;
import com.android.ahat.heapdump.Diff;
@@ -29,7 +28,6 @@
import com.android.ahat.heapdump.Value;
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -249,47 +247,16 @@
private void printGcRootPath(Doc doc, Query query, AhatInstance inst) {
doc.section("Sample Path from GC Root");
List<PathElement> path = inst.getPathFromGcRoot();
-
- // Add a dummy PathElement as a marker for the root.
- final PathElement root = new PathElement(null, null);
- path.add(0, root);
-
- HeapTable.TableConfig<PathElement> table = new HeapTable.TableConfig<PathElement>() {
- public String getHeapsDescription() {
- return "Bytes Retained by Heap (Dominators Only)";
- }
-
- public long getSize(PathElement element, AhatHeap heap) {
- if (element == root) {
- return heap.getSize();
- }
- if (element.isDominator) {
- return element.instance.getRetainedSize(heap);
- }
- return 0;
- }
-
- public List<HeapTable.ValueConfig<PathElement>> getValueConfigs() {
- HeapTable.ValueConfig<PathElement> value = new HeapTable.ValueConfig<PathElement>() {
- public String getDescription() {
- return "Path Element";
- }
-
- public DocString render(PathElement element) {
- if (element == root) {
- return DocString.link(DocString.uri("rooted"), DocString.text("ROOT"));
- } else {
- DocString label = DocString.text("→ ");
- label.append(Summarizer.summarize(element.instance));
- label.append(element.field);
- return label;
- }
- }
- };
- return Collections.singletonList(value);
- }
+ doc.table(new Column(""), new Column("Path Element"));
+ doc.row(DocString.text("(rooted)"),
+ DocString.link(DocString.uri("root"), DocString.text("ROOT")));
+ for (PathElement element : path) {
+ DocString label = DocString.text("→ ");
+ label.append(Summarizer.summarize(element.instance));
+ label.append(element.field);
+ doc.row(DocString.text(element.isDominator ? "(dominator)" : ""), label);
};
- HeapTable.render(doc, query, DOMINATOR_PATH_ID, table, mSnapshot, path);
+ doc.end();
}
public void printDominatedObjects(Doc doc, Query query, AhatInstance inst) {