我的android设备的Bitmap工厂出现OOM错误。
Out of memory on a 12582928-byte allocation.这对我来说很奇怪。它非常大。THe文件本身就是存储在平板电脑上并下载的图像。因此,图像的上限可能会达到1.2meg jpg左右。
在它显示该错误之后,它会显示致命异常的AndroidRuntime错误日志:
10-01 11:53:52.512: E/AndroidRuntime(31023): FATAL EXCEPTION: Thread-7893
10-01 11:53:52.512: E/AndroidRuntime(31023): java.lang.OutOfMemoryError
10-01 11:53:52.512: E/AndroidRuntime(31023): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
10-01 11:53:52.512: E/AndroidRuntime(31023): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:582)
10-01 11:53:52.512: E/AndroidRuntime(31023): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:380)
10-01 11:53:52.512: E/AndroidRuntime(31023): at com.bentley.cordova.plugins.ImageOps.createThumbnailForPath(ImageOps.java:43)
10-01 11:53:52.512: E/AndroidRuntime(31023): at com.bentley.cordova.plugins.ImageOps.execute(ImageOps.java:20)
10-01 11:53:52.512: E/AndroidRuntime(31023): at org.apache.cordova.api.PluginManager$1.run(PluginManager.java:192)
10-01 11:53:52.512: E/AndroidRuntime(31023): at java.lang.Thread.run(Thread.java:856)我确实有很多图像处理与此功能同时进行。我并不认为BitMapFactory在运行不同的线程时会超负荷工作。
发布于 2012-10-02 00:19:42
,这样图像的上限可能会达到1.2meg jpg左右。
那是胡说。32bit bitmap需要width * height * 4字节才能分配。记住当你不需要你的位图时使用recycle。如果可以,还要对其进行下采样。
发布于 2012-10-02 00:25:12
请考虑这样一个事实,1.2MB JPEG图像的位图表示可能很容易(取决于其压缩率)超过12MB。
当使用32位颜色时,位图至少需要宽*高*4字节来表示。
即使单个实例没有超过12MB标记,以线程方式运行它也可能超过JVM分配的最大堆大小。
https://stackoverflow.com/questions/12677091
复制相似问题