Object lifetime in old ASP

Source: Internet
Author: User
You may know that in the old ASP, you can still write some object-based Program . However, you may have some questions about the object's survival.

Constructor & destructor

Class someclass
Private   Sub Class_initialize
End sub

Private   Sub Class_terminate
End sub
End Class

Print a string in the destructor to confirm the object's survival.

Set someobject = nothing

In this way, the name someobject bound to an object is freed from this object and becomes an unbound name. But it does not necessarily mean that the bound object will be released. If

Set someobject1 = new csomeclass
Set someobject2 = someobject1
Set someobject1 = nothing

In this way, the object will not be parsed. Because someobject2 is still bound to the object, that is to say, the two names are actually bound to the same object.

Page ends

Objects without manual release are automatically released at the end of page execution.

Local object

Objects generated in sub and function are automatically released at the end of the process if they are not returned as return values and the return values are bound with names.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.