我已经阅读了许多关于解码位图的内存分配问题的相关帖子,但即使在使用官方网站提供的代码后仍然无法找到解决以下问题的方法.
这是我的代码:
public static Bitmap decodeSampledBitmapFromResource(InputStream inputStream, int reqWidth, int reqHeight) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
try {
while ((len = inputStream.read(buffer)) > -1) {
baos.write(buffer, 0, len);
}
baos.flush();
InputStream is1 = new ByteArrayInputStream(baos.toByteArray());
InputStream is2 = new ByteArrayInputStream(baos.toByteArray());
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(is1, null, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
options.inPurgeable = true;
options.inInputShareable = true;
options.inJustDecodeBounds = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
return BitmapFactory.decodeStream(is2, null, …Run Code Online (Sandbox Code Playgroud) 如何追踪Android开发中的内存泄漏?我正在开发eclipse IDE来开发应用程序.我无法找到如何纠正内存或窗口泄漏例外?任何的想法.
主要是窗口泄漏错误会引发非法参数异常?如何纠正这两个og.请帮忙.