nitin tyagi
nitin tyagi

Reputation: 1186

Optimization of Android Application

Hi I making a chat application . In that application i use a lots of bitmap. This application takes nearabout 55 mb space in memory. can anyone tell me how i optimize my application so that it takes less space in memory. Some friends suggest me for unbinding Bitmap but i have no idea about it. Can anyone help me . Thanks in advance.

Upvotes: 0

Views: 118

Answers (2)

Tal Kanel
Tal Kanel

Reputation: 10785

In that application i use a lots of bitmap

do you use lots of bitmaps in the same time?

do you holding references to bitmap objects when they are not actually needed anymore? if yes - don't do that!

do you decoding the bitmaps to the height and width that you actually need to display them? (the actual imageView size that will show them) if not - you should do that!

if you will take my suggestions and still consume so much native memory - you can do the "unbinding" as you called it, by invoke the Bitmap.recycle() method on bitmap object that don't needed anymore. this method frees the pixels array resides in the native memory associated with the bitmap.

the system frees this memory by itself if no one holds the bitmap reference anymore, but calling the recycle() method will cause the system to free the memory when you tell it. this can be useful if you are using lot's of bitmaps in a short amount of time, which the system usually did not triggering the memory freeing in that time.

Upvotes: 1

Chris Banes
Chris Banes

Reputation: 31871

Have you had a look at the 'Displaying Bitmaps Efficiently' Training class? http://developer.android.com/training/displaying-bitmaps/

Manually unbinding won't really help with your memory usage unless you have a memory leak somewhere. The call you may want to look at is Bitmap.recycle().

Upvotes: 3

Related Questions