Delphi about Resource Release Free_release_freeandnil
Source: Internet
Author: User
A little experience about resource release (Free/release/freeandnil) in Delphi
After this period of time to Delphi Free and release of careful study, summed up the following:
1. Form.free immediately after releasing the resource, the OnDestroy event is invoked, but the form pointer is not changed to nil
2. Form.release waits for the resource to be freed after it is no longer in use, and also without modifying the form pointer to nil, it is best to use release for resource deallocation in Destroy.
3. When a local variable frees a resource, consider releasing the resource with Freeandnil (), which can be more efficient and increase memory utilization.
4. When working on a form, it is not enough to judge whether a form has been created simply by assigned (Form1), because if the form is freed by Free/release, Form1 points to an unknown address instead of nil, so you need to use (not assigned (ShowForm)) and (ShowForm is TForm2) to determine if the form has been created in memory
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service