title: How i can to Destroy (free) a Form from memory?
body: <p>i have 2 Form (Form1 and Form2) in the my project, Form1 is Auto-create forms, but Form2 is Available forms.
  how i can to create Form2 and unload Form1?</p>
  
  <p>I received a "Access validation" Error in this code.</p>
  
  <p>Here is Form1 code:</p>
  
  <pre><code>1.  uses Unit2;
  //*********
  2.  procedure TForm1.FormCreate(Sender: TObject);
  3.  var a:TForm2;
  4.  begin
  5.      a := TForm2.Create(self);
  6.      a.Show;
  7.      self.free;  // Or self.destory;
  8.  end;
  </code></pre>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>I modified that "Serg" code to this :</p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;
  
  type
    TForm1 = class(TForm)
      Button1: TButton;
      procedure Button1Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  var
    Form1: TForm1;
  
  implementation
  
  uses Unit2;
  
  {$R *.dfm}
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    Application.CreateForm(TForm2, Form2);
    Release;
  end;
  
  end.
  </code></pre>
  
  <p>///</p>
  
  <pre><code>program Project1;
  uses
    Forms,
    Unit1 in 'Unit1.pas' {Form1},
    Unit2 in 'Unit2.pas' {Form2};
  {$R *.res}
  begin
    Application.Initialize;
    Application.MainFormOnTaskbar := True;
    Form1:= TForm1.Create(Application);
    Application.Run;
  end.
  </code></pre>
  
  <p>but this project start and then exit automatically, Why?
  i want to show Form1 and when we click Button1 then show Form2 and free(Release) Form1. how i can to this?</p>