High memory usage (.NET)

Problem

After installing New Relic's .NET agent, you see an increase in Working Set memory usage in monitoring tools such as the Microsoft Windows Task Manager. The increase is usually about 100 MB per monitored application. This can occur on both physical and virtual machines.

Solution

This increased Working Set memory usage usually does not affect performance. Windows reserves Working Set memory for a particular app, but it can be released at any time if another app needs the memory. This is normal and expected behavior for any Windows app.

In rare cases, particularly for systems with limited RAM or many app pools, memory usage can impact performance. If your performance is affected, try any of these options:

  • Enable instrumentation only for specific app pools
  • Add more RAM to the machine.
  • Remove some application pools from the machine.
  • Monitor performance to see if the increased memory usage shown in the Task Manager is actually impacting performance. If it is, release memory and share with other processes.

Cause

The underlying cause is the way Windows itself anticipates and allocates memory per process. Windows allocates this memory as Working Set memory, which is memory the operating system reserves for the process. The OS can release the Working Set memory quickly if another process needs it. Because memory allocation is decided by Windows, New Relic cannot reduce the amount of memory shown in use.

Usually this increase is not a problem unless there is a corresponding drop in performance. Performance problems may occur if all of the available memory is occupied as Private Working Set memory. If the server is running low on memory, monitor your response times and transaction times to see if this memory usage is actually impacting performance. If there is no increase for awhile, then the memory usage is not a problem.

Typically the Working Set memory usage only causes issues on systems with limited RAM. For example, New Relic's test systems may show an increase of approximately 100 MB per monitored app or app pool. An 80% increase is notable when it is 80% of 64 GB, but less notable when it is 80% of 4 GB.

Similarly, the number of application pools being monitored affects usage. A single app pool rarely increases usage significantly, but a system with 4 GB of RAM and 30 application pools might have issues.

For more help

Recommendations for learning more: