相关疑难解决方法(0)

尽管使用了减少的样本大小,但BitmapFactory.decodeStream内存不足

我已经阅读了许多关于解码位图的内存分配问题的相关帖子,但即使在使用官方网站提供的代码后仍然无法找到解决以下问题的方法.

这是我的代码:

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 bitmap out-of-memory

13
推荐指数
2
解决办法
2万
查看次数

跟踪Android中的内存/窗口泄漏?

如何追踪Android开发中的内存泄漏?我正在开发eclipse IDE来开发应用程序.我无法找到如何纠正内存或窗口泄漏例外?任何的想法.

主要是窗口泄漏错误会引发非法参数异常?如何纠正这两个og.请帮忙.

android memory-leaks

8
推荐指数
1
解决办法
5393
查看次数

标签 统计

android ×2

bitmap ×1

memory-leaks ×1

out-of-memory ×1