出上System.Drawing.Image.FromFile内存异常() [英] Out Of Memory exception on System.Drawing.Image.FromFile()

查看:654
本文介绍了出上System.Drawing.Image.FromFile内存异常()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图片上传和栽跟头它创建缩略图和我偶尔会在下一行内存异常的out:

I have an image uploader and cropper which creates thumbnails and I occasionally get an Out Of Memory exception on the following line:

Dim bm As Bitmap = System.Drawing.Image.FromFile(imageFile)

错误的次数是微小的,非常罕见的,但我总是想知道什么可能导致它。的镜像文件变量只是使用Server.Mappath到图像的路径。

The occurance of the error is tiny and very rare, but I always like to know what might be causing it. The imageFile variable is just a Server.MapPath to the path of the image.

我很好奇,如果任何人有pviously遇到此问题$ P $,如果他们有任何想法可能是什么造成的呢?它是图像的大小吧?

I was curious if anyone had experience this issue previously and if they had any ideas what might be causing it? Is it the size of the image perhaps?

我如果有必要,我有任何佐证信息发布code,但很想听到人们在这一个观点。

I can post the code if necessary and any supporting information I have, but would love to hear people's opinions on this one.

推荐答案

这是值得了解OutOfMemoryException异常并不总是确实的意思是它的内存不足 - 与文件打交道时,特别不。我相信,如果你因为某些原因用完句柄它也有可能发生。

It's worth knowing that OutOfMemoryException doesn't always really mean it's out of memory - particularly not when dealing with files. I believe it can also happen if you run out of handles for some reason.

您处理所有的位图你与他们完成后?这是否针对单个图像重复地发生呢?

Are you disposing of all your bitmaps after you're done with them? Does this happen repeatably for a single image?

这篇关于出上System.Drawing.Image.FromFile内存异常()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆