Link to home
Start Free TrialLog in
Avatar of gtas
gtas

asked on

Do I need to free memory from dynamically created form?

Hi,

I have a Delphi 2 app using MDI.  The application only allows ONE copy of each window to be in existance.  Code fragment is....

///////////////////////////////////////////////////
procedure TMainForm.CommissionPlanMenuClick(Sender: TObject);
var
  Child: TCommPlanF;
  N    : Integer;  
begin
 
 
  { create a new MDI child window }
  Child := nil;
  with Application.MainForm do
    for N := 0 to MDIChildCount - 1 do
      if MDIChildren[N] is TCommPlanF then
        Child := MDIChildren[N] as TCommPlanF;
  if Child = nil then
    Child := TCommPlanF.Create(Application)
  else {_ NOT if Child = nil then _}
    with Child do
    begin
      if WindowState = wsMinimized then WindowState := wsNormal;
      BringToFront;
    end; {_ with Child do _}
end; {_ procedure TMainForm.CommissionPlanMenuClick(Sender: TObject); _}

///////////////////////////////////////////////////////

This dynamically creates the window.  The question becomes...  Do I need to do something to free the memory after the window is closed or is this done for me automatically?  If I need to free the memory, do I use the TFORM.RELEASE method?

Thanks
GTAS
ASKER CERTIFIED SOLUTION
Avatar of julio011597
julio011597

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of julio011597
julio011597

Ah... anycase, to free a form - as any other Object - the correct way to go is:

MyForm.Free;