According to the daily programming experience, we can get some experience about the release of resources in Delphi.
If there is an object obj is a tobject type:
1 Obj.free The resource directly, the OnDestroy event is invoked, but the OBJ pointer value is not placed as nil.
2) Obj.release wait for resources to release resources after they are no longer in use, and also do not modify OBJ pointers to nil, so it is best to use release for resource deallocation in OnDestroy.
3 Local variables to release resources, you can consider using Freeandnil () to release resources, so the efficiency is higher, can improve the utilization of memory.
4 It is not enough to judge whether an object has been created simply by assigned (obj), because obj points to an unknown address instead of nil if the object is freed through free/release, so you need to use (not assigned (OBJ)) and ( Not (the OBJ is TObject) to determine if the object has been created in memory.