Skip to content

Commit

Permalink
Add excluded refs to leak info
Browse files Browse the repository at this point in the history
Fixes square#119

Result:

```
* Excluded Refs:
| Field: android.view.inputmethod.InputMethodManager.mNextServedView
| Field: android.view.inputmethod.InputMethodManager.mServedView
| Field: android.view.inputmethod.InputMethodManager.mServedInputConnection
| Field: android.view.inputmethod.InputMethodManager.mCurRootView
| Field: android.animation.LayoutTransition$1.val$parent
| Field: android.view.textservice.SpellCheckerSession$1.this$0
| Field: android.accounts.AccountManager$AmsTask$Response.this$1
| Field: android.media.MediaScannerConnection.mContext
| Field: android.os.UserManager.mContext
| Field: android.view.Choreographer.FrameDisplayEventReceiver.mMessageQueue
| Static field: android.support.v7.internal.widget.ActivityChooserModel.mActivityChoserModelPolicy
| Static field: android.widget.ActivityChooserModel.mActivityChoserModelPolicy
| Thread:FinalizerWatchdogDaemon| Thread:main| Thread:LeakCanary-Heap-Dump
```
  • Loading branch information
pyricau committed May 18, 2015
1 parent 189920e commit fbdc604
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public static String leakInfo(Context context, HeapDump heapDump, AnalysisResult
} else {
info += "* NO LEAK FOUND.\n\n";
}
if (detailed) {
detailedString += "* Excluded Refs:\n" + heapDump.excludedRefs;
}

info += "* Reference Key: "
+ heapDump.referenceKey
+ "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ private ExcludedRefs(Map<String, Set<String>> excludeFieldMap,
this.excludedThreads = unmodifiableSet(new LinkedHashSet<>(excludedThreads));
}

@Override public String toString() {
String string = "";
for (Map.Entry<String, Set<String>> classes : excludeFieldMap.entrySet()) {
String clazz = classes.getKey();
for (String field : classes.getValue()) {
string += "| Field: " + clazz + "." + field + "\n";
}
}
for (Map.Entry<String, Set<String>> classes : excludeStaticFieldMap.entrySet()) {
String clazz = classes.getKey();
for (String field : classes.getValue()) {
string += "| Static field: " + clazz + "." + field + "\n";
}
}
for (String thread : excludedThreads) {
string += "| Thread:" + thread;
}
return string;
}

public static final class Builder {
private final Map<String, Set<String>> excludeFieldMap = new LinkedHashMap<>();
private final Map<String, Set<String>> excludeStaticFieldMap = new LinkedHashMap<>();
Expand Down

0 comments on commit fbdc604

Please sign in to comment.