About dispose ()

Source: Internet
Author: User
Tags dotnet
When I read the DOTNET document with a good mood, dispose entered my sight with disgust.
First, I realized that some objects must be manually called with dispose, which is not a joke. The requirements mentioned in this document are serious. For example, sqlconnection, although you do not manually call dispose or close, in some cases, because the system will automatically call those in some cases; but in other cases, if you do not call dispose or close, the connection pool will be quickly cleaned up.
Secondly, dispose makes me very frustrated that it is not easier to control than the heap memory pointer of C ++. We have just determined that dispose (or similar alternative method) must be manually called for some objects, otherwise it is prone to problems. OK. Next, I found that if we forget to release somewhere, we can hardly determine which damn place we forgot to release, it can be exactly where the resources are exhausted; and until the resources are exhausted, you can hardly find this problem; and when the resources are exhausted, you have no way to detect when resources are exhausted. If such a problem is found in a large project module, some people will go crazy. Therefore, some people say that DOTNET is not suitable for large projects, which is somewhat reasonable. In contrast, although the heap memory pointer of C ++ needs to be released, we can at least easily detect memory leaks.

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.