I'm building an app where you have the function to upload a post with an image. When the user picks the image I show a thumbnail of it but when I change the screen orientation I get a memory leak. I managed to get it down to the point where it takes about 25 orientation changes to leak memory but can I completely avoid it?
This is the code I use for the bitmap,
private ImageView miniPicture;
private String imagePath;
private WeakReference<Bitmap> imageBitmap;
....
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
imageBitmap = new WeakReference<Bitmap>(BitmapFactory.decodeFile(imagePath, options));
miniPicture.setImageBitmap(imageBitmap.get());