Insufficient Memory Error when launching application for second time after calling finish() in main activity..

by Streets Of Boston » Tue, 21 Apr 2009 22:21:19 GMT


Sponsored Links
 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.




--~--~---------~--~----~------------~-------~--~----~



Insufficient Memory Error when launching application for second time after calling finish() in main activity..

by quakeboy » Wed, 22 Apr 2009 20:48:38 GMT


 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 ?





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Insufficient Memory Error when launching application for second time after calling finish() in main activity..

by quakeboy » Wed, 29 Apr 2009 20:51:58 GMT


 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





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. geo Intent

Can someone tell me how to request a blue dot (or some such marker) to
show on the map corresponding to my passed lat/lon parameters?  The
API works great and centers the map with respect to the point in the
center of the screen.  However, the map menu is pretty much useless in
terms of directions to/from this "mystery" location.  I realize I can
s{*filter*}this design and use a MapActivity, but that opens up a new can
of worms that I'd rather not deal with.

Peace,
Scott

-- 

2. Pass image to a new Intent

Hi
I've got a problem
My app show a first layout like:

Gridview1 (3 images in 1 row)
ImageView1 (1 image)
Gridview2 (3 images in 1 row)
ImgaeView2 (1 image)
Gridview3  (3 images in 1 row)
ImgaeView3 (1 image)

When you clik over an image it will be open full screen in a second
layout

The problem was that I don't know how to pass the image to the new
intent

Now I've the next code:

public AdapterView.OnItemClickListener pulsarImagen = new
AdapterView.OnItemClickListener()
    {
                public void onItemClick(AdapterView<?> arg0, View arg1, int
arg2,long arg3)
                {
                        Intent intent = new Intent(GridViewer.this , 
GalleryViewer.class);
                        intent.putExtra("id", arg0.getItemIdAtPosition
(arg2));
                        startActivity(intent);
                        //finish();
                }
    };


But the ItemID is always 0...

Before I've only one gridview and then I passed the item's position.
But now I've 3 different gridviews and I don't know if the position of
item selecte it's from gridview 1,2 or 3.

I supose that the great solutin it will be to pass the id resource
(image) but I don't know how to pass it.

Can you help me?

ENM

-- 

3. Memory leaks in Android Application / Framework

4. How do you determine the IP address of the mobile client over 3G?

5. It depends!

6. discarding large touch events ViewRoot.java

7. Flurry AppCircle