Re: [android-developers] Do we need to call System.gc() ?

2010-08-10 Thread Greg Donald
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


[android-developers] Do we need to call System.gc() ?

2010-08-09 Thread Alex Xin
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.

Thanks  BRs,

Alex

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