title: memory leak vs. access violation, class design issue
body: <p>I show a short design pattern for a user class  in the code below.</p>
  
  <pre><code>type
    MytestClass = class
      alist: TStringlist;
    public
      constructor Create;
      destructor destroy; override;
    end;
    { MytestClass }
  
  type
    TForm1 = class(TForm)
      btn_version01: TBitBtn;
      btnversion02: TBitBtn;
      procedure FormClose(Sender: TObject; var Action: TCloseAction);
      procedure FormCreate(Sender: TObject);
      procedure btn_version01Click(Sender: TObject);
      procedure btnversion02Click(Sender: TObject);
    private
      { Private-Deklarationen }
    public
      { Public-Deklarationen }
  
      btestClass : MytestClass;
      aComplexClassDesign : TComplexClassDesign;
    end;
  
  var
    Form1: TForm1;
  
  implementation
  
  {$R *.dfm}
  
  constructor MytestClass.Create;
  begin
    alist := TStringlist.Create;
  end;
  
  destructor MytestClass.destroy;
  begin
    alist.free;
    inherited;
  end;
  
  
  procedure TForm1.btnversion02Click(Sender: TObject);
  var atestClass : MytestClass;
  begin
       ///
    atestClass :=MytestClass.Create;
    atestClass.Free;
    atestClass := nil;
  end;
  
  procedure TForm1.btn_version01Click(Sender: TObject);
  var atestClass : MytestClass;
  begin
       ///
    atestClass :=MytestClass.Create;
    atestClass.Free;
  end;
  
  procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  begin
    btestClass.free;
    aComplexClassDesign.Free;
  end;
  
  procedure TForm1.FormCreate(Sender: TObject);
  begin
    btestClass :=MytestClass.Create;
    aComplexClassDesign :=TComplexClassDesign.Create;
  end;
  
  end.
  </code></pre>
  
  <p>Hope this is a perfect design without Memory leaks and Access violations. All the classes I use in my real application are designed along this pattern.</p>
  
  <p>FastMM4 does not show up any problem on my TComplexClassDesign in the code above. In the real application FASTMM4 is reporting a Memory leak for my TComplexClassDesign, even I call the free function in the Close Event of the form. If I step the through the code for sure this function is executed.
  Any idea how to debug this memory leak report, any option to see the instance of TComplexClassDesign which has not been released? Any other reason why I got this strange memory leak report ?</p>
  
  <p>Bonus question :</p>
  
  <p>DUnit always make teardown code like this</p>
  
  <pre><code>  atestClass :=MytestClass.Create;
    atestClass.Free;
    atestClass := Nil
  </code></pre>
  
  <p>Is the last line of code really needed ?</p>