0
I am working with a Main Form and it has several Panels. In one of them, the "Geral panel" I use to call the instances of new forms and show in it using the following code of the Formcall class:
public void chamaFormulario(Form form)
{
Form activeForm = frmMain.ActiveForm;
foreach (Panel painel in activeForm.Controls )
{
if(painel.Name == "panelGeral")
{
painel.Controls.Clear();
if(form != null)
{
form.TopLevel = false;
painel.Controls.Add(form);
form.Show();
}
}
}
}
For example, when the program opens I call a Welcome Form as follows:
private void frmMain_Shown(object sender, EventArgs e)
{
frmInicio frm = new frmInicio();
formCall = new FormCall();
formCall.chamaFormulario(frm);
}
When I call the form frmClientes and when opening it, it has a "Back" button that aims to return to the welcome screen, which calls the following method:
private void btVoltarClientes_Click(object sender, EventArgs e)
{
frmInicio frm = new frmInicio();
FormCall form = new FormCall();
form.chamaFormulario(frm);
}
But noting the memory consumption in the VS2017 Community diagnostic tool, what was consuming 60MB over to 96MB, and if I open the customer form again and press back again, it goes up to 136MB... And so on and so forth.
What should I do to solve this high memory consumption?
This occurs after you click the button a few times?
– Maniero
Maniero. Yes! But the Rovann solution I think solved the problem.
– WitnessTruth