Large memory ASP.NET application - leak?

I have an ASP.NET website that seems to be using a lot of memory. I left it for 7 hours on Sunday and it reached 3.2 GB. I thought .NET handles all its garbage collection objects / free 'd etc., so I'm not sure where to start looking for a solution.

The website uses XML heavily, so I thought this might be a problem, but I used the global use of XMLSerializer to try to eliminate this.

I also have a custom handler that processes all the images, resizes, caches, and then loads from the cache where it can. Could this be causing any problems?

Sorry I'm so vague, but the problem is that I don't know where to start with this problem. Any help was appreciated.

Server Information: .NET 2.0 Server Windows 2008 IIS7

Thanks in advance.

+4
source share
4 answers

The best place to start is using a profiler. RedGate has an ANTS Memory Profiler, which is really good and has a free trial. Product page here.

You launch the application, attach the profiler and start using the page as usual. The profiler collects information about the objects used, and this should help you determine the root cause of the problem.

Once in my application, it turned out that we accidentally created an NHibernate SessionFactory for each individual request that we made. All were listed inside NHibernate, which meant they were never released in addition to being terribly slow and ineffective. The profiler leads us to this, and we would never have found it otherwise.

+5
source

An alternative to RedGate is to use adplus and WinDbg. Also read this blog:

http://blogs.msdn.com/tess/

This is a great source of help with debugging issues.

My SysAdmin and I successfully used adplus and WinDbg to detect a memory leak in an ASP.NET application. My mistake for the developers was that they accidentally used the ASP.NET cache without expiration.

Another mistake was that the developer used Attribute overloads with XMLSerialization. Thanks to this .net function, everything will create a new serializer assembly (independently). Assemblies cannot be unloaded, so the application eats a lot of memory

+2
source

When working with the file system, it is really important that you manage your readers and temporary objects.

+1
source

You say you use XmlSerializer a lot. This causes a memory leak if you do not use the default constructors XmlSerializer (type) and XmlSerializer (type, defaultNameSpace).

See this MSDN article for more information.

+1
source

Source: https://habr.com/ru/post/1302843/


All Articles