Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an 3.5 application running on Windows Server 2003 and IIS 6.0 that when my code reads a 16MB file I sometimes get an OutOfMemory exception. Usually if you try to perform the same read again I continue to get the exception.

If I restart w3svc then the exception goes away. Also it tends to go away if I leave it alone for a few hours and try running the code later.

The exception comes from a call to ReadToEnd on the file stream, so it's not something in my code leaking memory.

The w3wp.exe process on my website is usually using about 250-350MB of memory under normal load.

I would guess that something about per-connection memory usage or something is causing this problem, though I don't know enough about the IIS / memory management to know where to look for a way to track this down or tweak it to not cause the problem.

I almost always have 2+GB free RAM on this server, and am never below 1.5GB free.

I've run this same application / code for years on these servers and this exception only started recently. My guess is that it started when the file slowly grew above 16M, but that could just be a coincidence. The file most definitely slowly grows so a few months ago when I was never having this problem, it was most definitely a bit smaller than it is now.

The offending code is probably run 5-6 times a day (reading in a cache) and seems to error once or twice a week so it does not always error, but its frequent enough that it is becoming a problem.

Is there some sort of limit to the IIS connection or the website that I'm hitting and if so is there a way to increase the limit when I know I have loads of free RAM?

share|improve this question
I'm running into a similar problem, did you ever find a solution? – Jaap Nov 29 '12 at 13:19
@Jaap Take a look at this: The basic solution is to add /3GB to your boot.ini file – thelsdj Dec 4 '12 at 7:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.