0

I have a website which prepared with ASP.NET MVC 3 and Entity Framework 4.1. This image below is my server's perfmon logs.

My problem is w3wp.exe is getting bigger and bigger at every minutes and never release. I'm using LINQ to Entities in my queries and all my entity framework codes are in using block.

I think it's a garbage collection problem, but I am not sure. What is my problem and how can I fix it?

Perfmon Logs' image about my issue

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vai
  • 19
  • 7
  • 2
    If you aren't running out of memory this is not a problem. .NET will allocate memory it needs, but will not release it back to the system unless necessary as it is cheaper performance wise. Other than that, your question is likely to be closed because 1) there are lots of similar questions here and 2) it is utterly impossible to answer "What is my problem and how can i fix it?" when talking about an application we've never seen and we don't even know if there *is* a problem in the first place. –  Sep 09 '11 at 17:23
  • thanks for your comment but i did write here it because clr memory logs make me curius about garbage collection after a few hours w3wp.exe can get 600MB or higher. As you can see Finalization survivors aren't normal i think because they are keeping get higher. is GC working? I can add one more picture from now. – Vai Sep 09 '11 at 17:31
  • Without presenting the results of a process dump using ADPlus and some analysis by WinDBG there is very little scope for help from the community here. I suggest you go and read [Tess Ferrandez's blog](http://blogs.msdn.com/b/tess/) and get up to speed with debugging memory leaks. She has a great lab series to get you started here: http://blogs.msdn.com/b/tess/archive/2008/02/04/net-debugging-demos-information-and-setup-instructions.aspx – Kev Sep 09 '11 at 21:59

2 Answers2

1

It all depends on what your web site is doing. We have .NET servers running on 32 GB RAM, and the worker process gladly takes all it wants. It needs it really.

Are you running a lot of background threads, stored an abhorrent amount of data in the session/global application / static methods?

Are connection strings, readers, file I/O, etc. being closed properly?

.NET garbage collection works great, but you have to do your part. Garbage collectors (waste disposal engineers) are not going to go into your house and collect it for you, you have to at least walk it to the curb... or close / null / dispose of objects you're not using.

Update 1:

What is happening is the ASP.NET worker process is creating a buffer. When it hits a certain amount of memory used, it will decrease over time, but it likes to allocate memory so it doesn't have to go out of it's way to fetch it when it needs it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ryan Ternier
  • 8,714
  • 4
  • 46
  • 69
  • thanks for your comment, its a game server's management site and my server has 2gb ram and im not the only one who use it so i need to take care of it. i use entity framework in using blocks as i said in the question i think it does its job closing connections etc. im not using IO and multi-threads as well. when the visitors hit my site, ram is being increased and never released that's my problem. – Vai Sep 09 '11 at 17:51
  • i did as much as i can null for my list objects that im using to pass itself to view. Because they are getting done with linq query and returned to view. i have never call Dispose() anywhere because i dont have any class has it. – Vai Sep 09 '11 at 17:54
  • 2GB of ram for any web server is not enough. Heck, 2GB of ram isn't enough for my work station. – Ryan Ternier Sep 09 '11 at 17:54
  • you are right. i need to move another vps which has 4gb or 8gb thing. – Vai Sep 09 '11 at 18:01
  • but first i need to know how can i fix this stuation, i dont want to on other vps goes through to 8gb ram. – Vai Sep 09 '11 at 18:03
  • What I would do is get a profiler to check your code. http://stackoverflow.com/questions/49912/best-net-memory-and-performance-profiler . I have used ANTS, it's good if your application is not CPU intensive .If it is, try http://www.jetbrains.com/profiler/ – Ryan Ternier Sep 09 '11 at 18:11
0

You should run a profiler to see what process and threads are getting out of hand. Visual Studio 2010 has some nice profiling tools, and I'm sure there are some other third-party ones as well.

It very well could be poor coding from the developer, and garbage collection might not be doing its role as Ryan mentioned above. Especially if your application uses multiple threads.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69