Здравствуйте! Делаю большое web приложение(сайт) на Silverlight. В качестве сервиса для доспупа данных использую обычный WCF service(.svc). C БД работаю при помощи обычного DateReader.
Проблема в том, что после загрузке портала на хостинг через минут 40-60 данные на сайт перестают поступать и сервис выдаёт такую ошибку:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
Memory gates checking failed because the free memory (485363712 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InsufficientMemoryException: Memory gates checking failed because the free memory (485363712 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InsufficientMemoryException: Memory gates checking failed because the free memory (485363712 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.]
System.ServiceModel.Activation.ServiceMemoryGates.Check(Int32 minFreeMemoryPercentage, Boolean throwOnLowMemory, UInt64& availableMemoryBytes) +58980
System.ServiceModel.HostingManager.CheckMemoryCloseIdleServices(EventTraceActivity eventTraceActivity) +95
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +584
[ServiceActivationException: The service '/MainService.svc' cannot be activated due to an exception during compilation. The exception message is: Memory gates checking failed because the free memory (485363712 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element..]
System.Runtime.AsyncResult.End(IAsyncResult result) +495736
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178
System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +348782
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +9663393
Я понимаю что где-то идёт утечка памяти, подскажите как избавиться от этой проблеммы?
методы которые я использую для работы с БД в сервисе выглядят вот так:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
public List<GetAllUser> GetAllUsers(int id)
{
using (SqlConnection sqConn = new SqlConnection(ConfigurationManager.ConnectionStrings["VSMconnection"].ConnectionString))
{
List<GetAllUser> Data = new List<GetAllUser>();
sqConn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqConn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "[Web].[GetAllPersons]";
cmd.Parameters.AddWithValue("@Id", id);
SqlDataReader sdr = null;
sdr = cmd.ExecuteReader();
while (sdr.Read())
{
var GetData = new GetAllUser
{
UserLog = sdr["Email"].ToString(),
UserAllName = sdr["Name"].ToString()
};
Data.Add(GetData);
}
sdr.Close();
sqConn.Close();
return Data;
}