Last post Feb 25, 2019 06:11 AM by AC Giant
Feb 21, 2019 08:20 PM|hansvonn|LINK
Our web-server has multiple instances of an asp.net web-forms site that use too much memory. The w3wp.exe processes take memory until the machine is near 100% of physical ram and then starts using cpu.
I have tried:
Is there any way to restrict how much memory an asp.net website can use? If not how can we see what is using the most memory? How can we keep memory usage in check? Thank you.
Feb 21, 2019 09:00 PM|DA924|LINK
Is the solution using n-tier and seperation of concerns with presentation tier, business tier and data access tier on seperate machines? Is the solution using datatable that is a resource hog? Is the application disposing of objects using the 'using' statement?
Feb 21, 2019 09:18 PM|mgebhard|LINK
Is there any way to restrict how much memory an asp.net website can use?
The Application Pool's Private Memory Limit restricts the amount of memory the worker process can use before restarting. You can find this setting in IIS Application Pools -> Advanced Settings.
If not how can we see what is using the most memory?
See the Performance Monitor.
How can we keep memory usage in check?
There's no one size fits all solutions. It sounds like a memory leak if the applications are not releasing memory. That's a programming bug that you need to find.
Feb 21, 2019 09:30 PM|PatriceSc|LINK
Which VS edition do you have ? I used https://docs.microsoft.com/en-us/visualstudio/debugger/using-dump-files?view=vs-2017 once and in particular
the "Debug Managed Memory" option. It shows the count and size for each type of object found un the dump which should help to narrow down what happens. Unfortunately it is not available in the Community Edition (maybe Pro if not Ultimate).
If using EF, try perhaps to trace how many objects are loaded in the context (maybe EF queries loading more data than needed causing an excessive memory consumption and garbage collection actiivity).
Feb 25, 2019 06:11 AM|lingmaaki|LINK
When a .NET application starts, it asks the OS for a chunk of memory which it then segments to become the managed heap, stack, and large object heap. It is this total chunk of memory that TaskManager is reporting, which may or may not be completely used
by .NET. Once a .NET application is given a chunk of memory, it will not release it until asked by the OS, which will only happen with the OS determines a need for more memory resources.
.NET will manage garbage collection for you very efficiently. While on types that implement IDisposable it is wise to call the Dispose method, this probably isn't your problem. Memory leaks can happen in .NET for a lot of reasons. Here are a few:
I hope this gives you some ideas about where to look.
Dec 11, 2019 06:16 PM|AC Giant|LINK
I also looking for how to optimize memory usage with IIS.
Anyway, you can set iis max memory usage in machine.config. The default is <processModel autoConfig="true"/> which is max 60% of memory. And you can override the memory limit with memoryLimit property.
"Configures the ASP.NET process model settings on a Microsoft Internet Information Services (IIS) Web server. The processModel section can be set only within the Machine.config file and affects all ASP.NET applications that are running on the server."
-- processModel Element (ASP.NET Settings Schema)