Câu hỏi phỏng vấn Android
Câu hỏi

How do you handle Bitmaps in And...

Câu trả lời

Here are some tips for handling Bitmaps efficiently in Android to avoid memory issues:

Use Bitmap Pooling

  • Bitmap pooling allows you to reuse Bitmap objects instead of constantly creating new ones
  • This reduces memory usage and improves performance
  • You can implement a simple Bitmap pool yourself or use a library like BitmapPool

Downsample Images

  • Decode images at a lower resolution than their original size
  • This reduces the memory footprint of the Bitmap
  • Use BitmapFactory.Options.inSampleSize to specify the downsampling factor

Use Bitmap Recycle

  • Call Bitmap.recycle() on Bitmaps you no longer need
  • This frees up the native memory used by the Bitmap
  • Be careful not to recycle Bitmaps that are still in use

Use Weak/Soft References

  • Use WeakReference or SoftReference to hold Bitmaps
  • This allows the garbage collector to reclaim the Bitmap memory if n...
senior

senior

Gợi ý câu hỏi phỏng vấn

middle

What is the difference between Activity and Context ?

middle

Android Log.v() , Log.d() , Log.i() , Log.w() , Log.e() . When to use each one?

expert

When to use AIDL vs Messenger Queue?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào