Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

しょこたん入門/AndroidとBitmapとOutOfMemory(公開用)

8,978 views

Published on

素敵なしょこたんの紹介と Android で Bitmap を使う際にはまったことをまとめてみました。

  • Be the first to comment

  • Be the first to like this

しょこたん入門/AndroidとBitmapとOutOfMemory(公開用)

  1. 1. • Android ( (^ω^))
  2. 2. ANDROID
  3. 3. OUTOFMEMORY•Bitmap OutOfMemory
  4. 4.
  5. 5. //Bitmap.createBitmap(WIDTH, HEIGHT...);Log.d(TAG, " ");Bitmap.createBitmap(WIDTH, HEIGHT...);Log.d(TAG, " ");2 OutOfMemoryhttps://gist.github.com/1131708https://gist.github.com/1046532
  6. 6. SOFTREFERENCE• SoftReference•
  7. 7.
  8. 8. Map<Integer, SoftReference<Bitmap>> map = new HashMap<...>();for (int i = 0; i < 1000; ++i) { Bitmap bitmap = Bitmap.createBitmap(...); map.put(i % 4, new SoftReference<Bitmap>(bitmap));} OutOfMemory
  9. 9. • OutOfMemory • IS06(Android 2.2) • Xperia arc(Android 2.3)• • Desire(Android 2.2) • IS05(Android 2.2)
  10. 10. GOOGLE IO• Google IO : Memory management for Android Apps• http://www.google.com/events/io/2011/sessions/memory- management-for-android-apps.html
  11. 11. BITMAPS Old way (pre-Honeycomb): – freed via recycle() or finalizer – hard to debug – full, stop-the-world GCse-Honeycomb):cycle() or finalizeruge-world GCs Managed Native
  12. 12. BITMAPS Old way (pre-Honeycomb): – freed via recycle() or finalizer – hard to debug – full, stop-the-world GCs New way:oneycomb): – freed synchronously by GCe()–or finalizer easier to debug – concurrent & partial GCsorld GCs Managed Native
  13. 13. • 3.0 GC• > GC > OoM >
  14. 14. • Bitmap.recycle()• SoftReference
  15. 15. • WebView

×