Reputation: 6676
When calling:
adb shell dumpsys
We get a list of Objects used by different processes:
Objects
Views: 171 ViewRootImpl: 3
AppContexts: 13 Activities: 3
Assets: 23 AssetManagers: 0
Local Binders: 681 Proxy Binders: 90
Parcel memory: 26 Parcel count: 89
Death Recipients: 9 OpenSSL Sockets: 0
WebViews: 0
We can also use the below API calls to print out local and proxy binder counts at runtime:
Log.d(TAG, "Local: " + Debug.getBinderLocalObjectCount() + " Proxy: " + Debug.getBinderProxyObjectCount());
How can we identify which Binder objects (classes) are in the list that produces the count?
I am trying to maintain a complex app (not written by me) and I am struggling to determine where Binders are leaking over time.
It is not until the app exhausts Binders that Android crashes the app and logs a "histogram" like this:
11-29 17:53:43.284932 1016 1059 V Binder : BinderProxy descriptor histogram (top 10):
11-29 17:53:43.285382 1016 1059 V Binder : #1: android.app.IServiceConnection x4160
11-29 17:53:43.285666 1016 1059 V Binder : #2: android.view.IWindow x1729
11-29 17:53:43.285827 1016 1059 V Binder : #3: android.content.IIntentReceiver x288
11-29 17:53:43.286048 1016 1059 V Binder : #4: android.database.IContentObserver x232
11-29 17:53:43.286146 1016 1059 V Binder : #5: <cleared weak-ref> x164
11-29 17:53:43.286215 1016 1059 V Binder : #6: x61
11-29 17:53:43.286286 1016 1059 V Binder : #7: android.content.IContentProvider x61
11-29 17:53:43.286367 1016 1059 V Binder : #8: android.app.IApplicationThread x51
11-29 17:53:43.286434 1016 1059 V Binder : #9: android.hardware.display.IDisplayManagerCallback x51
Surely there must be a list of 'handles' that are maintained. Is there any way in which we can relate these handles back to Binder constructors, or hook into an API function so we can log every single Binder creation?
Upvotes: 1
Views: 21