[Switch] Some experiences on resource release (Free/release/freeandnil) in Delphi
After studying free and release in Delphi during this period, we will summarize the following:
1. After the form. Free directly releases the resource, the ondestroy event is called, but the form pointer is not changed to nil.
2. Form. Release: Release the resource after the resource is no longer used. Also, the form pointer is not modified to nil. Therefore, it is best to use release to release the resource in destroy.
3. When releasing resources with local variables, you can use freeandnil () to release resources. This increases the efficiency and improves the memory utilization.
4. When operating the form, it is not enough to judge whether the form has been created by using assigned (form1) alone, because if the form is released through free/release, form1 points to an unknown address instead of nil. Therefore, you must use (not assigned (showform) and (not (showform is tform2 )) to determine whether the form has been created in the memory.