dacongy
dacongy

Reputation: 2552

android binders

Is it normal for an application to have approximately 100 instances of local binders? The number climbs to that high, and never drops down to what it initially is. What could be the scenarios to have this large number of binders?

Upvotes: 0

Views: 2616

Answers (1)

Adrian Taylor
Adrian Taylor

Reputation: 4114

(Rewritten as the author is asking about the number of local binders listed using adb shell dumpsys meminfo). I can't answer the question about whether this is normal, as I'd never spotted that command before!

But here is a bit of information about the scenarios which could cause it.

A local binder is any object which the Android 'Binder' kernel IPC driver believes can receive function calls from another process.

Such things could include:

  • Any objects you've declared within your code that derive from IBinder. There are always such objects when you're declaring an Android service. Very often you'll also create such objects (as listeners) when you're using someone else's service.
  • Equivalent Java IBinder-derived objects within the Android framework. In some cases this might be obvious, such as when you provide some sort of listener to some system service. But other Android framework classes often have Binders involved too. For example, I have a feeling that an Android Bitmap contains an IBinder somewhere within it, in order to arrange for different processes to share the bitmap data without needing to copy it. I'm not sure about that, though.
  • Parts of the Android framework which are in C++ are also Binders. For example, I think each Android application process has a connection to the graphics composition engine (surface flinger) called ISurfaceComposer.

So, to work out why you have so many Binders, think about these things:

  • Are you in any way expecting notification of any system event from some other process? For example a Broadcast Receiver, or any sort of listener you've passed to a system service, etc.
  • Do you yourself use Services and AIDL?
  • Are you passing complex Android framework classes into system APIs?

My gut feeling is that 100 is unusual; probably nothing actually to worry about, but I'd still be curious to know if you work out what the cause was.

Upvotes: 2

Related Questions