Calling recycle() accelerates how quickly your bitmap memory can be
returned to the heap. If it is convenient for you to call recycle(),
it can certainly help avoid OutOfMemoryErrors. However, with the
Bitmap object is garbage-collected, the finalizer will recycle() it
for you, so unless you are running into memory problems, calling
recycle() is not essential.

2012/1/11 杨辉 <[email protected]>:
> Hi,
>      If i get a bitmap with the codes like this:
>
>      bitmap = BitmapFactory.decodeResource(getResources(),
> imgList.get(imgIndex));
>
>      Should i need to free the memory of the bitmap with the following codes
> later.
> if(bitmap != null){
> {
> bitmap.recycle();
> bitmap = null;
> }
>
>      thank you ~~~
>
>
>
>
>
>
>
>
>
>
>
>      Codes as follows:
>
>       /**
>        * 只负责读取图片的线程
>        */
>       class LoadImage extends Thread {
>               int imgIndex = 0;
>
>               public void run() {
>                       while (true) {
>                               bitmap = 
> BitmapFactory.decodeResource(getResources(),
>                                               imgList.get(imgIndex));
>                               imgIndex++;
>                               if (imgIndex == imgList.size())//如果到尽头则重新读取
>                                       imgIndex = 0;
>                       }
>               }
>       };
>
>
>
>
>
>
>
> --
> 杨辉
> Impossible is nothing!
>
>
>
> ------------------------------------------------------------------------------------
> HDExplorer APK (A Nice File Manager,Simplicity but not simple.)
>
> Google Market:
> https://market.android.com/details?id=com.hd.explorer
>
> Google Code:
> http://code.google.com/p/hdexplorer/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to