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