<p>if Form.Release is called after using the form, it will free all related memory but not set the form variable to nil.</p>

<pre><code>if not assigned (Form1) then
  begin
    Application.CreateForm(Tform1, Form1);
    try
      // Do something
    finally
      Form1.Release
    end;
  end;
</code></pre>

<p>To be able to call the same code again, Form1 would have to be set to nil at some point. From the description of Release I cannot do</p>

<pre><code>Form1 := nil;
</code></pre>

<p>right after Release, because the Release procedure will return directly after being called and before the form is actually freed. I cannot detect when Form.Release is finished to set the form var to nil.</p>

<p>What is the best way to do this?</p>

In Delphi Win32, the appropriate way to free objects is to call
```
```
FreeAndNil(Form1)
```
```
This does both jobs in a single call.
However, I have a sneaking feeling there's more to your question than meets the eye. Are you using Delphi for .NET - and if so, which version?