I recommend reading Effective C++ -- and then avoiding C++ entirely.
You get the best of both worlds that way. :=)

(As an experienced C++ programmer, I claim that if you advocate C++ as
a primary programing language -- you don't know C++ as well as you
think you do! But if you're going to use it at all, you'd better know
it well. Myer's book is a good start.)

Such cleanup-verifier finalizers are relatively harmless -- but the
same result can be had using weak references, with the distinct
advantage of doing the reporting in a more controlled time and
environment.

On Aug 16, 4:05 pm, fadden <[email protected]> wrote:
> On Aug 11, 10:03 am, Indicator Veritatis <[email protected]> wrote:
> FWIW, _Effective Java_ was written by Josh Bloch.  Myers wrote
> _Effective C++_.  (I highly recommend both.)
>
> > Of course, it doesn't help that even those of us who should know
> > better confuse the Java notion of 'finalizer' with the C++ notion of
> > 'destructor'. They are not as close as they may seem; finalizers are
> > only very occasionally useful since, as you point out, there is no way
> > to be sure they are even called.
>
> They're useful when the primary content is, "assert(cleanup is done)".
>
> Some changes to the GC and the way Bitmaps work will appear in a
> future Android release.  The best thing you can do right now is use
> Bitmap.recycle() if you have knowledge of your Bitmap life span, since
> that discards the pixel data buffer without needing to go through the
> garbage collection mechanism at all.  (It still has to do the
> finalizer dance, but the small native structs associated with every
> Bitmap aren't counted against the VM heap limit.)

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

Reply via email to