且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

内存不足异常加载从外部存储位图时,

更新时间:2023-01-11 18:32:25

也许没有错,你的API的使用,我想我们所能做的是推断使用AssetManager涉及较少背后的幕后堆分配比打开一个随机从SD卡中的文件。

Probably nothing wrong with your API usage, I guess all we can do is infer that using the AssetManager involves less behind-the-scenes heap allocation than opening a random file from the SD card.

800KB是任何人的书了严重的分配......这无疑是为DECOM pressed图像像素。既然你知道图像的大小,什么深度是什么?如果它32bpp的然后尝试覆盖,使用 在preferredConfig

800KB is a serious allocation in anybody's book... this will doubtless be for the decompressed image pixels. Given that you know the size of the image, what depth is it? If it's 32bpp then try overriding that using inPreferredConfig.