@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (videoPlayerInterface != null) { videoPlayerInterface.onDestroy(); } videoPlayerInterface = null; if (controlsHandler != null) { controlsHandler.removeCallbacksAndMessages(null); } controlsHandler = null; appOffer = null; Drawable drawable = ctaImage.getDrawable(); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap bitmap = bitmapDrawable.getBitmap(); bitmap.recycle(); } ctaImage.setImageDrawable(null); ctaImage.destroyDrawingCache(); ctaImage = null; ingamewallVideoLayout.removeAllViews(); ingamewallVideoLayout = null; System.gc(); }
public void onDestroy() { Log.d(TAG, "onDestroy()"); // TODO: unbind to avoid memory leak... super.onDestroy(); iv.destroyDrawingCache(); if (yourSelectedImage != null) yourSelectedImage.recycle(); if (imageWithBubbles != null) imageWithBubbles.recycle(); }
// http://code.google.com/p/android/issues/detail?id=8488 public void recycleDrawables() { List<ImageView> images = new ArrayList<ImageView>(); // collect all the image views recycleDrawablesRecursive(this, images); for (ImageView imageView : images) { imageView.destroyDrawingCache(); Drawable d = imageView.getDrawable(); if (d != null && d instanceof BitmapDrawable) { imageView.setImageDrawable(null); BitmapDrawable bd = (BitmapDrawable) d; Bitmap bmp = bd.getBitmap(); if (bmp != null) { bmp.recycle(); } } } }