I tried to break it down to the main code regarding the pix array:
public class BitmapProcessor {
int[] pix;
public Bitmap run(Bitmap b)
{
pix = new int[picw * pich];
bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich);
// do some stuff
bm = Bitmap.createBitmap(picw, pich, Bitmap.Config.ARGB_8888);
bm.setPixels(pix, 0, picw, 0, 0, picw, pich);
pix = null;
return bm;
}
}
After this I still see pix in the monitor. Even if I click on Cause GC. Is the array being referenced inside the bitmap or why does it still exist?
nullactually makes the GC free the memory. This leads to the question whypixis not a local variable in your case? That would make it "go away" when the scope of the method is left.