3

We are developing a large ASP.NET application. The Application uses the below:

  • Entity framework as a data access layer.
  • WCF as a communication layer, that uses the ChannelFactory to create channels, (each call has a new channel), the WCF services are hosted in a windows services and uses WSHttpBinding.
  • SQL Server 2008 R2

  • Sometimes, we are using the TransactionScope in the business layer to create transactions.

  • The database contains large amount of data, that is passed through WCF.
  • All our Entity Framework ObjectContext are wrapped inside using statemnt to ensure they are disposed.
  • Each WCF Channel is disposed after it is used.
  • We have long running transactions that runs in the background, which contains many and frequent database access also through WCF.

Mainly we have two critical problems:

  • we have some kind of memory leak. The Memory of the WCF service host keeps increasing up and up especially with large data.
  • The Memory of the SQL server also increases up and up.

These problems makes the application very slow and sometimes does not respond, which force us to restart the wcf and sql services.

The application is hosted on a windows server 2008 environment that has 4 GB RAM.

Ghyath Serhal
  • 7,466
  • 6
  • 44
  • 60
  • How many users and whatz the amount of memory you are dealing with, do you have any profiler stats ? – V4Vendetta Jun 16 '11 at 10:37
  • We have 4 GB RAM and the number of users is about 6, 7. – Ghyath Serhal Jun 16 '11 at 10:39
  • 3
    SQL Server - left alone on a machine on its own - will always grab as much memory as it needs / as it can get. That's normal, expected behavior - no reason for worry (and that's why SQL Server is best given its own, exclusive server machine) – marc_s Jun 16 '11 at 10:40
  • I tried this scenario, I still had the same problem. – Ghyath Serhal Jun 16 '11 at 10:43
  • I had a similar experience.. did you trace through the steps? in our experience it had to do with the "fixups" done by EF.. I never found the solution other than deleting the context and recreating it. – hanzolo Mar 09 '12 at 07:20
  • I did not find the problem exactly. What do you mean by deleting the context and recreating it? – Ghyath Serhal Mar 09 '12 at 12:44

1 Answers1

3

Hopefully this shall get you started:

  1. Check the WCF diagnostics, if there is any exception or unexpected behaviour.
  2. Then use some memory profiling tools to see which objects stay in the WCF host memory.
  3. Verify that connection to the MS SQL is closed and disposed properly on a per request manner
  4. Check if you are doing any data caching and verify that there is no old data left.
  5. Profile MS SQL.
Community
  • 1
  • 1
oleksii
  • 35,458
  • 16
  • 93
  • 163