Bonjour, J'ai une application Web hébergée sur l'environnement suivant. Un seul cœur, 1 Go de RAM, disque dur de 40 Go, 700 Go de bande passante. Currenlty 4-6 utilisateurs y travaillent. Il existe un formulaire Gérer la politique dans lequel toutes les règles sont affichées dans la grille. Pour cela, je retourne une datatable à partir de la méthode statique. Mon structuer est le suivant,La structure suivante provoque-t-elle une fuite de mémoire?
private void BindGrid(object sortExp) // Method to bind Grid
{
DataTable dt = PolicyAccess.GetAllPolicy(some parameters for filter);
GRV1.DataSource = dt;
GRV1.DataBind();
dt.Dispose();
}
J'ai la méthode suivante statique dans la classe non statique qui retourne 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;
}
je suit une méthode statique dans une classe statique « GenericDataAccess » pour exécuter la commande
La structure ci-dessus (objet statique et méthode) cause-t-elle une fuite de mémoire?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;
}
S'il existe des utilisateurs simultanés, l'utilisateur aura-t-il la possibilité de voir d'autres données utilisateur?
Est-ce que retourner une table de données coûtera une consommation de mémoire élevée? –
"cela dépend juste de la quantité de données et de l'efficacité de la conception db" – user2586804
merci pour votre aide –