Flutter Android – 相机内存不足

huangapple go评论68阅读模式
英文:

Flutter Android - Camera Out of Memory

问题

我在Android上拍多张照片时遇到了OOM异常。我正在使用来自pub.dev的image_picker插件。

问题只在我拍摄高分辨率照片后出现。我记得在某处读到过,这个错误发生在调用相机(Intent)时。这可能是在实现中的某个地方?

尽管如此,我不能降低图像分辨率,因为我的应用程序依赖于高质量的图像。

有谁知道这个“问题”并有解决方法吗?

谢谢!

英文:

I am getting OOM Exceptions when taking multiple pictures on Android. I am using the image_picker plugin from pub.dev.

The problem occurs only if I take high resolution pictures and only after I took some. I have a hard time remembering reading that this error occurs when the camera (Intent) is called. This would probably be somewhere in the implementation?

Nevertheless I cannot reduce the image resolution because my app relies on the high quality of the images.

Does anyone know about this "problem" and have a solution for it?

Thank you!

答案1

得分: 1

抱歉,image_picker是一个内存占用较大的工具,需要>4GB的内存才能稳定运行。我在一台3GB的设备上进行测试,几乎100%的时间都会发生内存不足(OOM)错误。

您可以直接使用Flutter示例代码来实现相机功能,不过劣势是您需要提供自己的用户界面,并且拍摄的照片不会保存到相册,所以这只是一个部分解决方案。

英文:

Unfortunetely image_picker is a massive memory hog - It needs >4GB to work consistently. I'm testing on a 3GB device and it'll OOM pretty much 100% of the time.

You can implement the camera directly using fluter example code.. disadvantage is you have to supply your own UI and the images don't go into the photo gallery.. so it's only a partial solution.

huangapple
  • 本文由 发表于 2023年3月31日 23:12:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75900105.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定