Yeah, the system process holds a reference on it, which won't be released
until it GCs.

On Thu, Jul 16, 2009 at 2:46 AM, Guillaume Perrot
<guillaume.p...@gmail.com>wrote:

>
> It appears that I have to wait some minutes before I can see the
> finalize trace of my binder, but it eventually happens.
> Maybe some sort of timeout in android code.
>
> 2009/7/16 Guillaume Perrot <guillaume.p...@gmail.com>:
> >
> > I eventually saw finalize() (just once) on the Binder object after
> > many tests.
> > My guess is that it's a soft reference, when using a WeakHashMap to
> > keep the binders in a pool, I realized that the pool was emptied after
> > each put meaning no hard reference has been kept. So I dropped the
> > pool solution.
> > However I thought soft references were freed only when the VM is near
> > out of memory which was not my case in my test (only 2MB allocated,
> > 4MB in total heap).
> > Could anyone explain me the life cycle of a binder object ?
> >
> > On Jul 16, 10:16 am, Guillaume Perrot <guillaume.p...@gmail.com>
> > wrote:
> >> I am developing an android service using aidl.
> >> I realized that the objects returned in Service.onBind() are never
> >> freed (e.g. finalize() is never called) even after onUnbind() and
> >> onDestroy() and playing with the eclipse GC button.
> >> I checked that the memory leak did not come from my Binder
> >> implementation (by using an intermediate stub class, the finalize() is
> >> actually called on the "proxied" instance).
> >> Even if I return something like
> >> return new Binder()
> >>     {
> >>       @Override
> >>       protected void finalize() throws Throwable
> >>       {
> >>          Log.v("tmp", "finalizing binder");
> >>          super.finalize();
> >>       }
> >>     };
> >> in onBind(), finalize is never called.
> >> As a workaround I use a pool for binder objects wrapping real
> >> implementations, and I reuse it but I wonder if it's safe.
> > >
> >
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to