Why does it need to be destroyed when connecting to the database?

Source: Internet
Author: User
Why do we need to destroy so many objects when connecting to the database? it seems that after connecting to the database, we need to destroy the connection, destroy the result set, and destroy the object handle. why?


Reply to discussion (solution)

Php programs do not reside in the memory. they are lost when used up and cannot be reused.
Therefore, the system resources it occupies should be released.
However, php has a built-in garbage collection mechanism. if you do not release it, it will release it for you.

Php does not need to be manually destroyed, but developing a good programming habit is the most important thing!

Php programs do not reside in the memory. they are lost when used up and cannot be reused.
Therefore, the system resources it occupies should be released.
However, php has a built-in garbage collection mechanism. if you do not release it, it will release it for you.


Even if the memory does not reside, that is, the memory is no longer used up. what should we do to release it? Isn't that an option?

Because databases are system resources (not php resources) that are not released, they cannot be used by others.

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.