XSLT存档  

不及格的程序员-八神

 查看分类:  ASP.NET XML/XSLT JavaScripT   我的MSN空间Blog
Asked 4 years, 11 months ago
I have an interesting problem with how Windows and .Net manage memory for Asp.Net applications that I can't explain myself. The problem is that I have a big Asp.Net application that after starts up can take about 1 GB memory according Resource Manager. We tried to test how many instances of the application we can run at the same time on a single machine with 14-16 GB memory.

First test is with an Azure Windows 2016 server with 8 vCPUs, 14 GB RAM, HDD.

After a few instances:

After 30 instances:

 

As you can see, private byes and working set of some instances reduced a lot. Based on what I read from how memory is managed (aka working set, physical memory, virtual memory, page files...), I can understand how the OS can take physical memory away from some idle processes for the others that are in need. So far so good.

Then we tested the same scenario with another Azure Windows 2016 server with 4 vCPUs, 16 GB RAM, but this one uses SSD.

After about 20 instances, we got OutOfMemoryException:

 

The key difference I could see is that memory of all those w3wp processes were still high. In other words, they were not reduced as in the test above.

My question is why the behaviors were different? What prevented the second cases from saving memory to page file (my guess!) and thus caused OutOfMemoryException?

 
  • Have you verified that the server has a pagefile? Perhaps someone has disabled it. – sisve Feb 13, 2018 at 11:43
  • Thank you, it is a pagefile problem :) It was still enabled, but somehow when SSD is used Windows doesn't page memory to file using that default setting.
    We had to change it from managed by Windows to a fixed pagefile size, e.g. 20 GB and things started working as we expected. 
    – Thuan Feb 15, 2018 at 15:57

1 Answer

Checking pagefile setting showed us that it was stilled enabled in "System managed size" mode but somehow Windows refused to use it for the w3wp processes. We tried to change it to custom size and set it to 20 GB and everything started working again as expected.
I must admit that I still don't know why Windows 2016 behaves like that when SSD is used though.

  •  Thuan, I am running into the same problem on a non-Azure Windows 2016 server (no SSDs) Hyper-V VM.
    My pagefile is set to "System managed size" with plenty of disk space and memory.
    The 2016 config seem to be exactly the same as my 2012 R2 web servers, but in the 2016 server the page file is not growing.
    Either that or the w3wp processes are refusing to use the page file as you described.
    I solved this temporarily by changing the "Idle timeout action" from suspend to terminate so that low traffic sites don't get paged out to disk.
    Any chance you made further progress on this? 
  •  @john The only thing I tried and worked for me was to change paged file mode to "Custom size". Other than that, I don't know what else could work :) 
posted on 2023-02-09 22:59  不及格的程序员-八神  阅读(13)  评论(0编辑  收藏  举报