gpt4 book ai didi

java - BitmapFactory for java 给出 OutOfMemory 异常,想要 > 12mb...不知道为什么它这么大

转载 作者:行者123 更新时间:2023-12-01 18:59:41 25 4
gpt4 key购买 nike

我的 Android 设备的位图工厂出现 OOM 错误。

Out of memory on a 12582928-byte allocation.

这对我来说很奇怪。它非常大。文件本身是平板电脑上存储并下载的图像。因此图像的上限可能达到 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 因不同线程的运行而过度工作。

最佳答案

So the images might reach a 1.2meg jpg or so at the upper bounds.

这不是真的。 32 位位图 需要 width * height * 4 字节才能分配。当您不需要位图时,请记住回收您的位图。如果可以的话,还可以对其进行下采样

关于java - BitmapFactory for java 给出 OutOfMemory 异常,想要 > 12mb...不知道为什么它这么大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12677091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com