delphi – Form does not unload from memory

Question:

Hello everyone, I need help. My form doesn't dump from memory so I can't call it again. Follow code below:

If formage=nil then
Begin

I create the form and in the onclose of the form

Action:=cafree:
Formage:=nil

Does anyone have an idea???

Answer:

Remove the 2 procedures informed from the OnClose procedure. And after displaying the Form (which logically occurred after creation) you apply destruction:

formage := Tformage.Create(Application);
formage.ShowModal;
FreeAndNil(formage);

Note that after the Display the destruction method is called! This is the correct way to control memory. Remembering that Delphi is weak in this management. In other words, within the formage form you must control the creation and destruction of your variables.

Scroll to Top