Привет, У меня есть веб-приложение, размещенное на следующем enviornment. Одиночный ядро, 1 ГБ оперативной памяти, жесткий диск 40 ГБ, пропускная способность 700 ГБ. Currenlty 4-6 пользователей работают над этим. Существует форма «Управление политикой», в которой вся политика получает вид в gridview. Для этого я возвращаю datatable из статического метода. Мой structuer нижеследовал,Может ли следующая структура вызывать утечку памяти
private void BindGrid(object sortExp) // Method to bind Grid
{
DataTable dt = PolicyAccess.GetAllPolicy(some parameters for filter);
GRV1.DataSource = dt;
GRV1.DataBind();
dt.Dispose();
}
Я следующий статический метод в странах, не статический класс, который вернуть DataTable
public static DataTable GetAllPolicy(string pmPolicyNo, int type)
{
// get a configured DbCommand object
DbCommand comm = GenericDataAccess.CreateCommand();
// set the stored procedure name
comm.CommandText = "proc_docGetAllPolicy";
// create a new parameter
DbParameter param = comm.CreateParameter();
param.ParameterName = "@pmPolicyNo";
param.Value = pmPolicyNo;
param.DbType = DbType.String;
comm.Parameters.Add(param);
// create a new parameter
param = comm.CreateParameter();
param.ParameterName = "@Type";
param.Value = type;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
// execute the stored procedure and save the results in a DataTable
DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
return table;
}
Я следующий статический метод в статическом классе «GenericDataAccess» выполнить команду
public static DataTable ExecuteSelectCommand(DbCommand command)
{
// The DataTable to be returned
DataTable table;
// Execute the command making sure the connection gets closed in the end
try
{
// Open the data connection
command.Connection.Open();
// Execute the command and save the results in a DataTable
DbDataReader reader = command.ExecuteReader();
table = new DataTable();
table.Load(reader);
// Close the reader
reader.Close();
}
catch (Exception ex)
{
Utilities.LogError(ex);
throw;
}
finally
{
// Close the connection
command.Connection.Close();
}
return table;
}
// creates and prepares a new DbCommand object on a new connection
public static DbCommand CreateCommand()
{
// Obtain the database provider name
string dataProviderName = NandiConfiguration.DbProviderName;
// Obtain the database connection string
string connectionString = NandiConfiguration.DbConnectionString;
// Create a new data provider factory
DbProviderFactory factory = DbProviderFactories.
GetFactory(dataProviderName);
// Obtain a database specific connection object
DbConnection conn = factory.CreateConnection();
// Set the connection string
conn.ConnectionString = connectionString;
// Create a database specific command object
DbCommand comm = conn.CreateCommand();
// Set the command type to stored procedure
comm.CommandType = CommandType.StoredProcedure;
// Return the initialized command object
return comm;
}
делает вышеуказанную структуру (статический объект и метод) причиной утечки памяти?
Если есть одновременные пользователи, будет ли возможность видеть другие пользовательские данные.
ли возврат таблицы данных будет стоить дорогостоящей памяти? –
", что просто зависит от объема данных и эффективности дизайна db" – user2586804
спасибо за вашу помощь –