locked
"System.OutOfMemoryException: Out of memory" from calling Image.FromFile RRS feed

  • Question

  • User-823196590 posted

    I wrote a simple web service that does some image file analysis.  It works fine on my DEV box but fails with this error on PROD with this line of code:

    myimg = Image.FromFile(sPath)

    This is the 2.0 framework and both boxes are W2K Servers, and the file happens to be a TIFF.  Again this works on DEV and used to work on an earlier 1.1 PROD version (the old 1.1 verison on the same PROD box also returns an Out Of Memory error).

    Friday, September 1, 2006 2:37 PM

All replies

  • User1439985827 posted
    TIFF's are usually a large file, a memory analysis might be helpful. Will it do this with other formats, like PNG or TIFF?
    Monday, September 4, 2006 5:54 PM
  • User1439985827 posted

    I found a few problems that might be causing this:

    1. The program does not have permissions to access the image file. (Yes, you can get an out of memory exception even if the problem is permission related)
    2. The BackgroundImage propery is set directly from the Bitmap.FromFile method.
    3. You are reading an image that is currently being written to. Make sure all file handles with a write lock to that image with write access are closed.

    Though I have read some people have had problems with the TIFF format before, it might be a problem with the framework.

    Monday, September 4, 2006 6:02 PM