English 中文(简体)
Do I have a memory leak in my website? [closed]
原标题:

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

问题回答

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.

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.





相关问题
LINQ Training: Native SQL Queries to LINQ

Can anyone point out some good LINQ training resources. Mostly interested in getting some developers that are very skilled with SQL up to speed using Lambda and LINQ queries. They are struggling with ...

How can i write Linq2Entities Query with inner joins

How can I get data from these related entities. I want to get these columns only: Term.Name , related Concept_Term.Weight, related Concept.Id I wrote the SQL but I don t want to use select t....

Linq to enties, insert foreign keys

I am using the ADO entity framework for the first time and am not sure of the best way of inserting db recored that contain foreign keys. this is the code that i am using, I would appreciate any ...

Linq to entity timing problem

I created a data model that has some views from my database as entities,when I create a linq statment that has part of this view s entities ,the time processor take to execute the linq statment is ...

热门标签