请教一下,关于BITMAP占用内存回收的问题。
现在做了一个图片上传功能,总是会提示内存溢出,刚刚开始一两张图片还是挺好,但是等用户慢慢的提交完成,然后后面又拍照打算传的时候,就会报出内存溢出,我就很纳闷,为什么之前已经上传完毕的图片所占用的内存,系统不会将它们回收的吗?顺带附上一段代码,这样帮忙看看,是否写法跟内存占用大有关系??
附一段代码:
mBitmap1 = getSmallBitmap(image_path); //options.inSampleSize 设置缩放之类的。
if(mBitmap1!=null)
mBitmap1=circle(mBitmap1); //方法见红字
//创建画布
mCanvas = new Canvas(mBitmap1);
//创建画笔路径
mPath = new Path();
//创建画笔
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
Bitmap circle(Bitmap bmp) {
if(bmp==null)return null;
int bmpWidth = bmp.getWidth();
int bmpHeight = bmp.getHeight();
float width = (float)Common.screenWidth/bmpWidth;
float height = (float)Common.screenHeight/bmpHeight;
Matrix matrix = new Matrix();
matrix.postScale(width,height);
Bitmap resizeBmp = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true);
if(!bmp.isRecycled()){
bmp.recycle();
bmp=null;
System.gc();
}
return resizeBmp;
}