Possible memory leak in Zxing's System.Drawing.Bitmap

时光总嘲笑我的痴心妄想 提交于 2019-12-04 10:12:14

If you're using the code from [1] then it looks rather incomplete. Nothing frees the memory allocated from AllocHGlobal, which would lead to out-of-memory condition.

This is not a MonoTouch bug - the zxing code should implement IDisposable on the Bitmap class and ensure everything gets freed when disposed (or when the GC runs its finalizer).

You can either complete the class (i.e. implement IDisposable) or copy/paste the part that provides you a byte[] buffer containing the image (and free the unmanaged memory once it's copied into the managed buffer).

[1] https://github.com/JohnACarruthers/zxing.MonoTouch/blob/master/Bitmap.cs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!