Hey i found a lot of help with this article
http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html

Hope it helps others too

On Apr 22, 5:47 pm, quakeboy <prasna...@gmail.com> wrote:
> Thnx for replying SOB..
> I found I was using all Animation objects like that and I changed it.
>
> Later, still I found it was crashing at one particular line.. It might
> be helpful for developers so here it is..
>
> ==========BEFORE===============
>
> I set a different background at runtime.. like this.. (Its a 320 x 480
> image)
> view.setBackgroundResource(R.id.mybgid);
>
> ===========NOW==============
>
> Now I removed that line and do this..
> Bitmap lastbg = null; (this is on top only)
>
> if (lastbg != null) lastbg.recycle();
> Bitmap b = BitmapFactory.DecodeResource(.....as req.....);
> BitmapDrawable bd = new BitmapDrawable(b);
> view.setBackgroundDrawable(bd);
>
> Now the final result..
> My application still crashes, but the crash frequency has reduced to
> 25%
>
> Now I am sorry, but Some Android Engineers from Google were stubborn
> telling that BitmapFactory and settings image resources never leak
> memory..
>
> But in my personal experience, I found When I load sprites for each
> level, initially after the level is over, I did not recycle() and then
> it crashed frequently.. later I did that at the end of each level and
> crash frequency dropped a lottt..
>
> I even tried System.gc() in lot of places... Guys have to understand..
> we use JAVA !!! not C++... we dont have delete operators.. or free
> ()... how the, am I supposed clear memory... Please GC better for
> images..
>
> Moreover through my application I have a lot of imageview for which I
> change their Image on touch event ACTION_DOWN like this...
>
> imgbtn.setImageResource(R.drawable.mouse_down_sprite);
>
> Does all this leak little amounts of memory ??
> Can someone tell me how to change this discussions subject ?
>
> On Apr 21, 7:21 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:
>
> > Do you statically cache objects?
> > If your activity is gone/finished, that does not necessarily mean that
> > your game's process has died. Static references/caches may still be
> > active.
>
> > On Apr 21, 7:06 am, quakeboy <prasna...@gmail.com> wrote:
>
> > > I have made a game with just one activity.. I just replace the views
> > > when I want to change screen. The game runs fine for a really long
> > > time inspite of what ever I do within the game.
>
> > > But once I close the main game, by calling finish on the only activity
> > > in the application, and then when I start again, within the next 30
> > > secs it crashes telling VM budget exceeded..
>
> > > When I don't have a dispose() or a delete method in JAVA.. how the, am
> > > I supposed to remove the objects used in memory..
>
> > >  moreover I have
> > > android:launchMode="singleInstance" in my manifest
--~--~---------~--~----~------------~-------~--~----~
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