1

First of all, I have seen this question:

IIS Express - increse memory limit

But it is not a duplicate, because all answers are pointing to the 64bit version of IIS Express. I need to support 32 bit! And 32 bit can support 2 GB RAM per process.


I was debugging a strange problem. So I created a Console Application which works fine:

//Simplifiy my application logic
var trash = new List<int>();
long mbUsed = 0;
while (mbUsed < 600)
{
    for (var i = 0; i < 100000; i++)
    {
        trash.Add(i);
    }
    GC.Collect();
    mbUsed = Process.GetCurrentProcess().WorkingSet64 / 1024 / 1024;
    Console.WriteLine(mbUsed + " MB used");
}

//Creating a image
var bitmap = new Bitmap(2000, 4000);

Basicly it fills the ram to 600 MB and then tries to create a large image.

Now if I paste the same code in an MVC Action, surprise, I get an OutOfMemoryException:

Out of Memory Exception

If I read it correctly, I am using less then 500 MB.

Memory consumption

So how can I use more RAM? For normal IIS I can change it on the application pool.

Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
  • Are you sure you've got your "Platform Target" build property set correctly to x86 for the Console application? How about you try skipping the Bitmap thing and simply increase your list in an endless loop until you get this error in both cases? Also, be sure to understand how the List class resizes its internal array when adding elements. Adding one element will not increase the used bytes by one! Lastly, I would expect you to hit the memory limit a little bit earlier in an IIS (Express or not) application because of the added web/app server overhead that you carry compared to a console app. – dnickless Jul 18 '17 at 20:04
  • 2
    32 bit IIS/IIS Expres cannot support 2GB. There are technically reasons why out of memory ezceptions start to occur when memory usage goes up to more than 1GB. Switch to 64 bit is a must if your web app does need more memory. – Lex Li Jul 18 '17 at 20:08
  • One more thing to understand: https://stackoverflow.com/questions/1087982/single-objects-still-limited-to-2-gb-in-size-in-clr-4-0 – dnickless Jul 18 '17 at 20:09
  • @LexLi ah thank you that was the missing part on my site. Now everything makes more sence. – Christian Gollhardt Jul 18 '17 at 20:36

0 Answers0