I think calling System.gc() doesn't immediately trigger the garbage
collection. So, relying on this all the time might not be a good idea.

-Kumar Bibek
http://techdroid.kbeanie.com

On Aug 11, 1:09 am, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> Yep, it works for me too. But i only use it when dealing with bitmaps
> just to be sure that the garbage collector will release raw binary
> image data for unreferenced Bitmaps.
>
> Actually, i call System.gc() before creating a new bitmap. This makes
> the code in your 'catch' clauses obsolete:
>
> 1. Call System.gc() to make sure that raw binary data is released in
> case the dalvik-vm didn't realise memory gets low.
> 2. Create a new bitmap.
>
> On Aug 10, 1:46 pm, Greg Donald <gdon...@gmail.com> wrote:
>
> > On Mon, Aug 9, 2010 at 11:16 PM, Alex Xin <xinxi...@gmail.com> wrote:
> > > Hi,
> > > Do we need to call System.gc() to indicate that system should do a garbage
> > > collection or just let system to choose when to collect garbage and free 
> > > it?
> > > Because my app will random FCs on certain phones, but if I add some calls 
> > > to
> > > System.gc(), then there were no FCs.
>
> > I do the same thing.  Blocks of code like this are very common in my apps:
>
> > try
> > {
> >   cards = BitmapFactory.decodeResource( resources, R.drawable.cards );}
>
> > catch( Error e )
> > {
> >   System.gc();
> >   cards = BitmapFactory.decodeResource( resources, R.drawable.cards );
>
> > }
>
> > It's not pretty, but it works great.
>
> > --
> > Greg Donald
> > destiney.com | gregdonald.com

-- 
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