Experience in Delphi on resource release (Free / release / freeAndNil) of

After this time delphi, free and release of careful study, first summarized as follows:
after 1.Form.free immediately release the resources, call OnDestroy event, but did not form pointer changed to nil
2.Form.release waiting for resources no longer in use after the release of resources, the same does not modify form pointers to nil, it is preferable to use the release resource destroy the release operation.
3. Local variables release resources, you can consider the release of resources with freeandnil (), so that efficiency will be higher, can improve memory utilization
4. In the form of operation, simply by whether assigned (form1) to determine the form has been created it is not enough, because if the form of resources released by the free / release, then, form1 points to an unknown address, not nil, it is necessary to use (not Assigned (ShowForm)) and (not (ShowForm is TForm2)) to determine whether the form has been created in memory

Reproduced in: https: //my.oschina.net/cookblack/blog/621374

Guess you like

Origin blog.csdn.net/weixin_33969116/article/details/92046060