Memory Leaks in ASP.NET

G

Guest

In my ASP.NET application, we are noticing appreciable memory leaks and the
main culprit appears to be System.String We use ResourceReader to read in a
resource file and we close and dispose the resourcereader object also. We
profiled the application using .NET Memory profiler and it appears that
garbage collection does not appear to be happening. Even after closing all
sessions memory for aspnet process remains pegged at the level it was.
Has anyone run across a similar situation? Any ideas would be greatly
appreciated.
 
S

Scott Allen

So the application leaks? Or it stays at a farily predictable 'high
water' mark?
 
G

Guest

Thanks to both of you for your replies.
at one of our client sites the application virtually became unusable pegging
the memory over 800 MB. In our tests with .NET Memory profiler the culprit
appears to be System.String when used with ResourceReader. Our tests also
indicated that even after all the sessions are closed the aspnet memory
remained high and never came down even after about 6 hours.
 
J

Josh

Its not likely to be the fault of the string. I bet its the Reader not
cleaning up. Try killing the reader.
 
K

Kevin Spencer

I agree with Josh. System.String is not going to cause any memory leaks. If
you abuse it, it can run your memory up quite a bit, but it will come back
down. On the other hand, ResourceReader is a disposable class that works
with files. Not closing and/or disposing such a class can cause a memory
leak.

Now, I know that you've stated that you close and dispose the
ResourceReader, but are you sure that you always do so? For example, is the
close and dispose in a Finally block of a Try/Catch block? If not, an
exception might prevent the ResourceReader from being disposed properly.

You might want to look for any other classes that expose unmanaged objects,
particularly classes that work with File IO.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
D

david youren

I have a similar problem with a memory leak in .net on a dual xeon
windows 2003 server. I notice a lot of posts about this leaks on a dual
xeon, what is your server running?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top