-
Notifications
You must be signed in to change notification settings - Fork 31
Question : IIS dotnet.exe memory management #51
Comments
AFAIK, the child process spawned by w3wp.exe respects memory/cpu consumptions set on the AppPool. |
I have verified that it works. An IIS worker process (w3wp.exe) and all the dotnet processes which are created as a child process of the w3wp.exe process are grouped in the same job object group and the Private Memory Limit and the CPU time limit is used to set the Job object limit. So, if you set the Private Memory Limit(KB) correctly, that should work. If it does not work immediately, maybe you need to recycle the worker process after setting the configuration to apply the configuration change in case the apppool is configured not to be recycled automatically when there is a configuration change. If the recycle happens, you can check the System Event viewer log and you will see this event log supposing you are using the DefaultAppPool worker process. <><><> Thanks, |
Thanks for looking into this and confirming that the child process dotnet.exe should be following whatever value is specified for Private Memory Limit and Process Affinity Mask. I've verified after recycling that enabling and setting a value for Process Affinity Mask does work however it appears that any value set for Private Memory Limit is still being ignored. I've attached a screen shot similar to my original post showing I've set a Private Memory Limit of 524277 however the dotnet.exe process is consuming far more than this even after an application pool recycle, IIS Reset, and reboot. Is there a proposed fix or workaround for this? |
@onesandzeros415 I have already verified that the Private Memory Limit (KB) works for the dotnet.exe process on my two test machines, one with Wondows 10 OS amd64 and the other Windows 8 OS. So, there is no fix nor workaround required. You would need to check if there is any mis-configuration. First, I'd like to inform that you should make sure that the dotnet.exe process shown in the task manager is really created by worker (w3wp.exe) process. Another thing is the actual private memory size should be obtained with a different way such as using powershell cmdlets, not Task manager because the working set memory is not matched to the private memory size which is used by the configuration. Here is how I tested this thing on my test machine with powershell cmdlets for your information. 1. First get the process id of w3wp.exe process. In this example, 472 is the process id value.NOTE: I assumed you are using a single AppPool such as DefaultAppPool.
2. Get the child process process id of the dotnet.exe with the worker process id (472) obtained in the previous step. In this example, 12128 is the process id of the child process of donet.exe.
3. Now get the current process memory used by the dotnet.exe. In this example, the private memory size value of dotnet.exe is 13356 KB.
4. Get the total value of private memory of w3wp.exe (39180) and the private memory (13356) of dotnet.exe. In this example, the total value is 52536 KB (=> 39180 + 13356).In that case, if we set the private memory value 50000, which is less than 52536, for the DefaultAppPool, the w3wp.exe will be recycled (old process is terminated and new process for w3wp.exe is created) when the total private memory usage is bigger than 50000 KB after some time. And when the w3wp.exe is recycled, the child process (dotnet.exe) is gracefully shutdown together and the dotnet.exe process will be gone. When there is a new request to the corresponding aspnetcore app, you will see a new process of dotnet.exe shown. Thanks, |
@onesandzeros415, Hi, is there any update? Can I close this? |
@jhkimnew I am sorry for the delay, it's been busy with the holidays. 1. The w3wp process itself remains consistently low : PS C:\WINDOWS\system32> get-process -id 4388 Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
2. Upon closer investigation I'm seeing some varying results with the dotnet process. Below are three samples a few seconds apart : Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
` PS C:\WINDOWS\system32> get-process -Id 3780 Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
PS C:\WINDOWS\system32> get-process -Id 3780 Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
Please keep in mind I've set 524277 KB as the Private Memory Limit. It appears that while not as large of a value as Task Manager/Resource Monitor get-process is showing the dotnet.exe process exceeding the Private Memory Limit set via IIS. Please let me know if you need any additional information and or if I need to make any changes to my configuration. Regards, |
Thanks for the reply. Unless you did any mistake, that can't happen. To narrow down your isse, can you check if you can recycle the w3wp.exe first? You should monitor the process id of w3wp.exe. If the process id is changed, you can say that the process is recycled. Thanks, |
I found that this issue can be reproducible only on down-level OS versions such as Win7 OS or Windows 2008 R2. The IIS feature of limiting private memory for Job object, in which the processes of w3wp.exe and dotnet.exe are combined, was implemented after Win7 OS version. |
What @jhkimnew said above. |
Sorry, but this answer is unacceptable. The documentation specifically states that it supports Window 7, 2008 R2: Yesterday, the dotnet.exe used so much RAM, it caused my entire server to become unresponsive, forcing me to cold reboot the server through my ISP. Is there a workaround for this? Interestingly, the dotnet.exe process starts out with over 500,000K allocated to it. As the process runs, it gradually exceeds over 1,000,000K of RAM. I was under the impression that .NET core was lighter than .NET classic. |
@Joebeazelman This repo is not used anymore. Please use Please notice that aspnetcore.dll is used by w3wp.exe, not by dotnet.exe. So, memory usage of dotnet.exe is not caused by aspnetcore.dll. |
From @onesandzeros415 on December 8, 2016 0:9
I apologize if this is a duplicate question however I've yet to find any concrete information on IIS dotnet.exe memory/cpu management. According to @DamianEdwards from September 17, 2015 via issue 364 IIS is still managing the process. The AppPool settings that control recycling, memory limits, etc. still apply.
Does this apply to limiting memory/cpu consumption of the dotnet.exe process itself? I'm curious as I've set a memory limit of 524 megabytes on an application pool and dotnet.exe is able to exceed this set limit. Setting process affinity also does not appear to work on the dotnet.exe process.
Any clarification on memory/cpu management of the dotnet.exe process via IIS would be helpful.
Copied from original issue: aspnet/Hosting#900
The text was updated successfully, but these errors were encountered: