summaryrefslogtreecommitdiff
path: root/ddms
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2013-05-28 17:33:24 -0700
committerSiva Velusamy <vsiva@google.com>2013-05-29 11:02:30 -0700
commit13e92929b4169eeae144588ed874aea96a44cb9b (patch)
tree2b77862b286dffdea0321b8921b8eb96cee38b34 /ddms
parent71ba7d5982a79b921d02e5d19efa59b1edea9954 (diff)
downloadswt-13e92929b4169eeae144588ed874aea96a44cb9b.tar.gz
Minor fixes to Native Heap Panel view
1. Fixes the child count in the library view. 2. The diff view used to show stack traces where new allocations were made. But the amount of memory allocated was the cumulative sum of all allocations made at that stack trace, rather than just the amount allocated between the current and previous snapshots. We detect that situation and only show the newly allocated memory. Change-Id: I6edabf38b0c0758221983edf15e0d0b76154b962
Diffstat (limited to 'ddms')
-rw-r--r--ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java21
-rw-r--r--ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java3
2 files changed, 24 insertions, 0 deletions
diff --git a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java
index 9eb6ddf..783e5e4 100644
--- a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java
+++ b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java
@@ -46,7 +46,28 @@ public class NativeHeapDiffSnapshot extends NativeHeapSnapshot {
NativeHeapSnapshot oldSnapshot) {
Set<NativeAllocationInfo> allocations =
new HashSet<NativeAllocationInfo>(newSnapshot.getAllocations());
+
+ // compute new allocations
allocations.removeAll(oldSnapshot.getAllocations());
+
+ // Account for allocations with the same stack trace that were
+ // present in the older set of allocations.
+ // e.g. A particular stack trace might have had 3 allocations in snapshot 1,
+ // and 2 more in snapshot 2. We only want to show the new allocations (just the 2 from
+ // snapshot 2). However, the way the allocations are stored, in snapshot 2, we'll see
+ // 5 allocations at the stack trace. We need to subtract out the 3 from the first allocation
+ Set<NativeAllocationInfo> onlyInPrevious =
+ new HashSet<NativeAllocationInfo>(oldSnapshot.getAllocations());
+ onlyInPrevious.removeAll(newSnapshot.getAllocations());
+ for (NativeAllocationInfo allocation : allocations) {
+ for (NativeAllocationInfo old : onlyInPrevious) {
+ if (allocation.stackEquals(old)) {
+ allocation.subtract(old);
+ break;
+ }
+ }
+ }
+
return new ArrayList<NativeAllocationInfo>(allocations);
}
diff --git a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java
index b786bfa..40b5421 100644
--- a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java
+++ b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java
@@ -56,6 +56,9 @@ public class NativeHeapProviderByLibrary implements ILazyTreeContentProvider {
if (element instanceof NativeHeapSnapshot) {
NativeHeapSnapshot snapshot = (NativeHeapSnapshot) element;
childCount = getLibraryAllocations(snapshot).size();
+ } else if (element instanceof NativeLibraryAllocationInfo) {
+ NativeLibraryAllocationInfo info = (NativeLibraryAllocationInfo) element;
+ childCount = info.getAllocations().size();
}
mViewer.setChildCount(element, childCount);