Understanding ASP.net Memory Leaks Using RedGate Memory Profiler

I am running a large ASP.net 4.0 website. It uses the popular .Net content management system, has thousands of content elements, hundreds of concurrent users - this is basically a heavy website.

Within 1 day, IIS7 workflow memory usage can increase to 8-10 GB. The server has 16 GB installed and is currently configured to reuse the application pool once a day.

I get pressure to reduce memory usage. Most of the memory usage is associated with caching large lines of data, but the cache interval is set to only 5-10 minutes, so these lines should eventually expire from memory.

However, after starting RedGate Memory Profiler, I see what, in my opinion, is a memory leak. I filtered the results of my list of instances with objects that are "stored in memory exclusively by remote objects" (I read on the RedGate forum that this way you detect memory leaks). This gave me a long list of lines that are stored in memory.

For each row, I use the Instance Retention Graph to see what holds it in memory. It seems that System.string objects were cached at some point by System.Web.Caching.CacheDependency. If I follow the graph in its entirety, it goes through various other classes, including System.Collections.Specialized.ListDictionary, until it reaches System.Web.FileMonitor. This makes sense since the lines are the paths to the file (images / PDFs / etc).

It seems that the CMS caches file paths, but these cached objects then "leak out". Over time, this increases and consumes RAM.

Sorry, this is a long wind ... Is there a way to stop these memory leaks? Or clean them without resorting to recycling the application pool? Can I find which class / code caches to see if I can fix the leak?

+6
source share
1 answer

This sounds like a very common problem of things left in memory as part of a session state. If in this case your only options are: 1. do not put so much material in each user session, 2. set the session lifetime to something shorter (by default, by default, 20 minutes), and 3. periodically recycle the application pool.

As part 1. I found that there are “good ways” and “bad ways” to present data in a data network control. You can verify that you copy only the data you need, and not accidentally save links to the entire data file.

0
source

All Articles