Change roots view to "rooted".
Instead of just showing roots in the roots view, show all objects
whose immediate dominator is the SENTINEL_ROOT.
Bug: 24613815
Change-Id: I96429d75395edfe109222e88d31cdc0bd87a7767
diff --git a/tools/ahat/src/AhatSnapshot.java b/tools/ahat/src/AhatSnapshot.java
index 43658f3..0bf064e 100644
--- a/tools/ahat/src/AhatSnapshot.java
+++ b/tools/ahat/src/AhatSnapshot.java
@@ -19,7 +19,6 @@
import com.android.tools.perflib.heap.ClassObj;
import com.android.tools.perflib.heap.Heap;
import com.android.tools.perflib.heap.Instance;
-import com.android.tools.perflib.heap.RootObj;
import com.android.tools.perflib.heap.Snapshot;
import com.android.tools.perflib.heap.StackFrame;
import com.android.tools.perflib.heap.StackTrace;
@@ -30,7 +29,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -47,6 +45,9 @@
// Map from Instance to the list of Instances it immediately dominates.
private Map<Instance, List<Instance>> mDominated;
+ // Collection of objects whose immediate dominator is the SENTINEL_ROOT.
+ private List<Instance> mRooted;
+
private Site mRootSite;
private Map<Heap, Long> mHeapSizes;
@@ -70,6 +71,7 @@
mDominated = new HashMap<Instance, List<Instance>>();
mRootSite = new Site("ROOT");
mHeapSizes = new HashMap<Heap, Long>();
+ mRooted = new ArrayList<Instance>();
ClassObj javaLangClass = mSnapshot.findClass("java.lang.Class");
for (Heap heap : mHeaps) {
@@ -79,6 +81,10 @@
if (dominator != null) {
total += inst.getSize();
+ if (dominator == Snapshot.SENTINEL_ROOT) {
+ mRooted.add(inst);
+ }
+
// Properly label the class of a class object.
if (inst instanceof ClassObj && javaLangClass != null && inst.getClassObj() == null) {
inst.setClassId(javaLangClass.getId());
@@ -126,8 +132,12 @@
return mSnapshot.getHeap(name);
}
- public Collection<RootObj> getGCRoots() {
- return mSnapshot.getGCRoots();
+ /**
+ * Returns a collection of instances whose immediate dominator is the
+ * SENTINEL_ROOT.
+ */
+ public List<Instance> getRooted() {
+ return mRooted;
}
public List<Heap> getHeaps() {