更新时间:2022-06-17 04:50:52
您正在创建一个11MB的图像的3份(位图
,流
, strBase64
)。因此,通过调用降低内存占用
You are creating 3 copies of an 11MB image(bitmap
, stream
, strBase64
). So reduce the memory usage by calling
bitmap.recycle();
下面这一行:
below this line:
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
同样,关闭流,当你用它做(以下 stream.toByteArray();
):
stream.close();
stream = null;
请记住,有没有保证内存会被这些电话后立即清洗。正确的方式来处理这种情况是块传输大文件块。
Remember that there is no guarantee that memory will be cleaned immediately after these calls. Proper way to handle this type of situation is to transfer large files chunk by chunk.