Skip to content

Commit

Permalink
Point the finger to stubs
Browse files Browse the repository at this point in the history
Fixes #2555
  • Loading branch information
pyricau committed Jan 2, 2024
1 parent 79a81cf commit 31f7c49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions shark-android/api/shark-android.api
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public abstract class shark/AndroidObjectInspectors : java/lang/Enum, shark/Obje
public static final field OBJECT_ANIMATOR Lshark/AndroidObjectInspectors;
public static final field RECOMPOSER Lshark/AndroidObjectInspectors;
public static final field SERVICE Lshark/AndroidObjectInspectors;
public static final field STUB Lshark/AndroidObjectInspectors;
public static final field SUPPORT_FRAGMENT Lshark/AndroidObjectInspectors;
public static final field TOAST Lshark/AndroidObjectInspectors;
public static final field VIEW Lshark/AndroidObjectInspectors;
Expand Down
13 changes: 13 additions & 0 deletions shark-android/src/main/java/shark/AndroidObjectInspectors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,19 @@ enum class AndroidObjectInspectors : ObjectInspector {
return state["java.lang.Enum", "name"]!!.value.readAsJavaString()!!
}
},

STUB {
override fun inspect(reporter: ObjectReporter) {
reporter.whenInstanceOf("android.os.Binder") { instance ->
labels + "${instance.instanceClassSimpleName} is a binder stub. Binder stubs will often be" +
" retained long after the associated activity or service is destroyed, as by design stubs" +
" are retained until the other side gets GCed. If ${instance.instanceClassSimpleName} is" +
" not a *static* inner class then that's most likely the root cause of this leak. Make" +
" it static. If ${instance.instanceClassSimpleName} is an Android Framework class, file" +
" a ticket here: https://issuetracker.google.com/issues/new?component=192705"
}
}
},
;

internal open val leakingObjectFilter: ((heapObject: HeapObject) -> Boolean)? = null
Expand Down

0 comments on commit 31f7c49

Please sign in to comment.