[fpc-pascal] Free member after inherited Destroy;

Michael Van Canneyt michael at freepascal.org
Sun Apr 14 17:36:17 CEST 2013



On Sat, 13 Apr 2013, Zaher Dirkey wrote:

> Is it safe to free memeber object after call inherited in Destroy?
> in Delphi/ObjFPC modes
> 
> type TMyObject=class(TObject)
>    FMyMember:TmyMemberObject;
> ....
> 
> destructor TMyObject.Destroy;
> begin
>   inherited Destroy;
>   FreeAndNil(FMyMember);
> end;

This should be OK, but I would not recommend it when using e.g. components.

Michael.


More information about the fpc-pascal mailing list